JdbcTemplate插入clob类型字段(oracle数据库)

使用clob类型时,如果字符串长度太大,最后会出错,

使用JdbcTemplate操作代码如下:

final LobHandler lobHandler = new DefaultLobHandler (); //定义一个lob的操作类  
   Object update_result = jdbc.execute(sql, new AbstractLobCreatingPreparedStatementCallback(lobHandler) {  
     
       @Override  
       protected void setValues(PreparedStatement pstmt, LobCreator lobCreator) throws SQLException, DataAccessException {  
            pstmt.setLong(1, Long.parseLong(app_id));
            pstmt.setInt(2, Integer.parseInt(result));  
            lobCreator.setClobAsString(pstmt, 3, result_log);//大文本CLOB字段,result_log为字符串  
            pstmt.setString(4, user);  
       }  
  }); 

你可能感兴趣的:(java,oracle)