Druid连接池处理clob字段
数据源相关
String sql = "{call insert_timestamp(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}";
DruidDataSource druidDataSource = (DruidDataSource) dataSource;
DruidPooledConnection conn = druidDataSource.getConnection();;
DruidPooledCallableStatement call = (DruidPooledCallableStatement) conn.prepareCall(sql);
处理方式
Clob clob= conn.createClob();
clob.setString(1, '插入或者修改的参数');
ClobProxyImpl clobProxyImpl = (ClobProxyImpl) clob;
clob= clobProxyImpl.getRawClob();
call.setClob(4, clob); //4为参数的位置
JDBC处理clob字段(下面内容为引用的其他博文,博文地址附在文尾)
方法一: Connection con = dbl.loadConnection(); strSql = “insert into
table1(id,a) values (1,EMPTY_CLOB())”; dbl.executeSql(strSql); String
str2 = "select a from table1 where id=1 "ResultSet rs = dbl.openResultSet(str2); if(rs.next()){
CLOB c = ((OracleResultSet)rs).getCLOB(“a”);
c.putString(1, “长字符串”);
String sql =
“update table1 set a=? where id=1”;
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setClob(1, c);
pstmt.executeUpdate();
pstmt.close(); } con.commit();
方法二: Connection con = dbl.loadConnection(); CLOB clob =
oracle.sql.CLOB.createTemporary(con,
false,oracle.sql.CLOB.DURATION_SESSION); clob.putString(1, “长字符串”);
Sql1 = “update table1 set a=? where id=1”; PreparedStatement pst =
con.prepareStatement(Sql1); pst.setClob(1, clob); pst.executeUpdate();
pst.close(); con.commit();
引用博文:https://www.cnblogs.com/dyllove98/archive/2013/07/30/3226222.html