更新clob类型的值
Posted aLa神灯
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了更新clob类型的值相关的知识,希望对你有一定的参考价值。
/** * 更新clob数据类型的值 * @param columnName * @param lids * @param para * @return */ public static boolean executeClobSQL(String columnName,String lids,String para){ boolean flag = false; Connection connection = null; PreparedStatement pstmt = null; ResultSet rs = null; Writer outStream = null; try { connection = GsUtil.getConnection(); //for update 锁定数据 pstmt = connection.prepareStatement(" select "+columnName+" from g3_log_info where lids=‘"+lids+"‘ for update"); rs = pstmt.executeQuery(); while(rs.next()){ oracle.sql.CLOB clobparas = (oracle.sql.CLOB) rs.getClob(1); outStream = clobparas.getCharacterOutputStream(); //data是传入的字符串,定义:String data char[] cp = para.toCharArray(); outStream.write(cp, 0, cp.length); } outStream.flush(); outStream.close(); connection.commit(); } catch (Exception e) { e.printStackTrace(); }finally{ GsUtil.closeConnection(rs, pstmt, connection); } return flag; }
以上是关于更新clob类型的值的主要内容,如果未能解决你的问题,请参考以下文章
使用kettle做orcale数据交换(插入/更新)时,遇到数据类型为CLOB的情况时就交换不了是啥原因?