当前位置:开发者网络 >> 技术教程 >> JSP教程 >> Java技巧及代码 >> 内容
精彩推荐
分类最新教程
分类热点教程
  
关于如何使用JdbcTemplate实现在WebLogic812,Oracle9i上的CLOB数据的写操作
作者:未知
日期:2005-04-30
人气:
投稿:(转贴)
来源:未知
字体:
收藏:加入浏览器收藏
以下正文:

进行写操作的方法

import java.sql.*;import org.springframework.jdbc.core.*;import org.springframework.jdbc.core.support. AbstractLobCreatingPreparedStatementCallback;import org.springframework.jdbc.support.lob.LobCreator;import org.springframework.jdbc.support.lob.LobHandler;import org.springframework.jdbc.support.lob.*;import org.springframework.jdbc.support.nativejdbc.*;
public void storeMessateContent(JdbcTemplate jdbcTemplate, String msg) throws      SQLException {    String sql = "insert into test (CONTENT)" +        "values (?)";    try {      OracleLobHandler handler = new OracleLobHandler();      handler.setNativeJdbcExtractor(new WebLogicNativeJdbcExtractor());      this.lobHandler = (LobHandler) handler;      jdbcTemplate.execute(sql,                           new AbstractLobCreatingPreparedStatementCallback(this.          lobHandler) {        protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws            SQLException {          lobCreator.setClobAsString(ps, 1, msg); //设置详细的CLOB字段的内容        }      }      );    }    catch (Exception ex) {      throw new SQLException(          "Update CLOB type column [CONTENT]  ERROR!");    }  }
程序测试环境:welogic812+springframework1.1+Oracle9i


相关文章: