码迷,mamicode.com
首页 > 其他好文 > 详细

更新clob类型的值

时间:2018-05-09 10:52:49      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:tst   on()   str   style   static   rac   mit   tco   sele   

/**
     * 更新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类型的值

标签:tst   on()   str   style   static   rac   mit   tco   sele   

原文地址:https://www.cnblogs.com/lxh520/p/9012743.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!