您现在的位置: 网页制作教程网 >> 数据库教程 >> oracle 教程 >> 文章正文

当Spring遇到了Oracle,该怎么办

作者:赛迪网

来源:赛迪网

热度:

2006-10-6 13:39:55

2,读写clob

这个要简单一些,不过要需要oracle的驱动不能用class12.zip那个,要从oracle下一个新的版本,具体多少不记得了。

/**
      * 基于主键的查询方法 根据给出的主键查询一个业务并返回
      * 
      * @param key
      * @return
      */
public List findByPrimaryKey(String key) {
logger.debug("finding service by primary key");
try {
return getJdbcTemplate().query(
"SELECT serviceid,contenttype,templatetext FROM table where serviceid='"+key+"'",
new RowMapper() {
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
String serviceid = rs.getString(1);
String contenttype = rs.getString(2);
String templatetext = lobHandler.getClobAsString(rs, 3);
return new SerVConTemPBean(serviceid, contenttype, templatetext);
}
});
} catch (RuntimeException re) {
logger.warn("finding service by primary key failed", re);
throw re;
}
}
     /**
      * 根据业务主键更新信息
      * @param key
      * @param params
      * @param types
      * @return
      */
public void updateContentByPrimaryKey(final String key,final String templatetext) {
logger.debug("update service content by content template primary key");
try {
getJdbcTemplate().execute(
 "update table set templatetext=? where serviceid=?",
new AbstractLobCreatingPreparedStatementCallback(this.lobHandler) 
{protected void setValues(PreparedStatement ps,
LobCreator lobCreator) throws SQLException {
lobCreator.setClobAsString(ps, 1, templatetext);
ps.setString(2, key);
}
}
);
} catch (RuntimeException re) {
logger.warn("update service by service primary key failed", re);
throw re;
}
            }

上一页  [1] [2] 

我来说两句:

1分 2分 3分 4分 5分
姓名: *


* 请各位网友遵纪守法并注意语言文明。
网站简介 | 联系方式 | 意见建议 | 版权说明
Copyright © 2007 All rights reserved
滇ICP备06006992号