4 Replies Latest reply on Sep 22, 2005 7:19 PM by reeser

    Class Cast Exception using Oracle CLOB

    reesear

      I am having issues with retrieving a CLOB out of an Oracle database using the Oracle driver CLOB object. I have to use the Oracle CLOB object instead of java.sql.Clob because I want to create a Writer out of the clob. It gives me a ClassCastException when I am retrieving the CLOB out of the resultset. I have tried using a regular connection from the JBoss pool and I have used a JBoss WrappedConnection, but with no success. I have also tried using the JBoss WrappedStatement, but the same problem. I have included a sample code of what I am trying. By the way, I am using JBoss 4.0.2.

       Statement stmt = null;
       ResultSet rs = null;
      Connection initConn = datasource.getConnection();
      Connection conn = ((WrappedConnection)
       initConn).getUnderlyingConnection();
      
      stmt = conn.createStatement();
      sqlStr = "SELECT external_data "
       +"FROM external_data "
       +"WHERE external_data_id = "+extDataIdParam
       +" FOR UPDATE";
      
      rs = stmt.executeQuery(sqlStr);
      
      if (rs.next())
      {
       oracle.sql.CLOB destClob = ((OracleResultSet)rs).getCLOB (1);
       writer = destClob.getCharacterOutputStream();
       ...
      }
      


      Any help is appreciated,
      Rich