当前位置导航:炫浪网>>网络学院>>网页制作>>JSP教程

关于如何使用JdbcTemplate实现在WebLogic812,Oracle9i上的CLOB数据的写操作


进行写操作的方法

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


相关内容
赞助商链接