日期:2014-05-16  浏览次数:20346 次

Oracle clob字段的插入

PreparedStatement pstmSel = conn.prepareStatement(INS_TOPIC_UPDATE);
            pstmSel.setInt(1, topic.getTopicId());
            ResultSet rs = pstmSel.executeQuery();    
            if (rs.next())    
            {    
                 oracle.sql.CLOB clob = (oracle.sql.CLOB) ((com.mchange.v2.c3p0.impl.NewProxyResultSet)rs).getClob("topicContent");              
                 //weblogic.jdbc.vendor.oracle.OracleThinClob clob = (weblogic.jdbc.vendor.oracle.OracleThinClob)rs.getClob("topicContent");
              Writer outStream = clob.getCharacterOutputStream();    
                     //data是传入的字符串,定义:String data    
                     char[] c = CodeFilter.htmlEncode(topicContent).toCharArray();    
                     outStream.write(c, 0, c.length);    
                     outStream.flush();    
                     outStream.close();     
            }    
            conn.commit();
            rs.close();
            pstmSel.close();