java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.DelegatingResultSet cannot be cast to oracle.jdbc.driver.OracleResultSet
本来是CLOB 与Clob的问题 ,也是不能转换,后来用了
if (rs.next()) {
//                CLOB clob = rs.getClob(1);
             CLOB   clob   =   ((OracleResultSet)rs).getCLOB(1);
//                clob.putString(1, StringUtils.htmlToText(Content));
                clob.setString(1, StringUtils.htmlToText(Content));
                String s3 = "update articles set content2=? where id=?";
                pstmt2 = conn.prepareStatement(s3);
                pstmt2.setClob(1, clob);
                pstmt2.setInt(2, id);
                pstmt2.executeUpdate();
                conn.commit();
            }就有了上面的异常

解决方案 »

  1.   

    CLOB  clob  =  ((OracleResultSet)rs).getCLOB(1); 
    杂个都不对撒
      

  2.   

    同样的问题,把JAVA代码放在JSP页面里就可以了。
      

  3.   

    /**
    *
    *数据库中clob字段的内容
    *
    * */
    public void write() throws SQLException,IOException {
    String sql = "update " + tableName + " set " + fieldName + "=empty_clob() where " + primaryKey + "=" + primaryValue;
    //Connection conn = getConnection();
    conn.setAutoCommit(false);PreparedStatement pstmt = conn.prepareStatement(sql);
    pstmt.executeUpdate();sql = "select " + fieldName + " from " + tableName + " where " + primaryKey + "=" + primaryValue;
    Statement st = conn.createStatement();
    ResultSet rs = st.executeQuery(sql);java.sql.Clob clob ;
    if (rs.next()) {
    clob = ((oracle.jdbc.OracleResultSet)rs).getClob(fieldName);
    //clob = ((org.apache.commons.dbcp.DelegatingResultSet)rs).getClob(fieldName);
    oracle.sql.CLOB my_clob = (oracle.sql.CLOB)clob;
    OutputStream writer = my_clob.getAsciiOutputStream();
    byte[] contentStr = this.getContent().getBytes();
    writer.write(contentStr);
    writer.flush();
    writer.close();
    }conn.commit();
    rs.close();
    st.close();
    pstmt.close();
    conn.setAutoCommit(true);
    }