CLOB.createTemporary throws ClassCastException - fyi

From: Chris <cb3786_at_camail.sbc.com>
Date: 18 Feb 2004 13:14:44 -0800
Message-ID: <b386e78d.0402181314.57711db0_at_posting.google.com>


I use websphere connection pooling and had a failure attempting a CLOB.createTemporary.

    tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION); Here's an excerpt of the exception and stack-trace.   java.lang.ClassCastException:
com.ibm.ejs.cm.proxy.OracleConnectionProxy

     at oracle.jdbc.driver.OracleConnection.physicalConnectionWithin (OracleConnection.java:5128)

     at oracle.sql.CLOB.createTemporary(CLOB.java:1010)
     at oracle.sql.CLOB.createTemporary(CLOB.java:956)

I replaced the CLOB.createTemporary statement with the following code.  This worked around the CLOB.createTemporary failing. Hopefully this helps you if you have the same problem.
  CallableStatement stmt = null;
  try{
    stmt = conn.prepareCall("{ call DBMS_LOB.CREATETEMPORARY(?, TRUE) }");

    stmt.registerOutParameter(1, OracleTypes.CLOB);     stmt.execute();
    tempClob = (CLOB)stmt.getObject(1);
    ...
  } finally {
    if ( stmt != null ) {
      try {stmt.close();} catch (Throwable e) {}     }
  }
  // Be sure to do a tempClob.freeTemporary() after you're done with it (i.e., inserted or updated a column with it). Received on Wed Feb 18 2004 - 22:14:44 CET

Original text of this message