zoukankan      html  css  js  c++  java
  • 更新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;
        }
  • 相关阅读:
    todo-list
    codeforces 794 (#414 DIV1+DIV2)
    2018bnu校赛总结
    codeforces 743D
    HDU-2196 Computer (树形DP)
    HDU- 1005 Number Sequence(矩阵快速幂)
    HDU- 4000 Fruit Ninja(树状数组)
    codeforces 505C
    codeforces 286B
    codeforces 3D
  • 原文地址:https://www.cnblogs.com/lxh520/p/9012743.html
Copyright © 2011-2022 走看看