CLOB.createTemporary throws ClassCastException - fyi

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris

    CLOB.createTemporary throws ClassCastException - fyi

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

    tempClob = CLOB.createTemp orary(conn, true,
    CLOB.DURATION_S ESSION);

    Here's an excerpt of the exception and stack-trace.
    java.lang.Class CastException:
    com.ibm.ejs.cm. proxy.OracleCon nectionProxy
    at oracle.jdbc.dri ver.OracleConne ction.physicalC onnectionWithin
    (OracleConnecti on.java:5128)
    at oracle.sql.CLOB .createTemporar y(CLOB.java:101 0)
    at oracle.sql.CLOB .createTemporar y(CLOB.java:956 )

    I replaced the CLOB.createTemp orary statement with the following code.
    This worked around the CLOB.createTemp orary failing. Hopefully this
    helps you if you have the same problem.
    CallableStateme nt stmt = null;
    try{
    stmt = conn.prepareCal l("{ call DBMS_LOB.CREATE TEMPORARY(?, TRUE)
    }");
    stmt.registerOu tParameter(1, OracleTypes.CLO B);
    stmt.execute();
    tempClob = (CLOB)stmt.getO bject(1);
    ...
    } finally {
    if ( stmt != null ) {
    try {stmt.close();} catch (Throwable e) {}
    }
    }
    // Be sure to do a tempClob.freeTe mporary() after you're done with
    it (i.e., inserted or updated a column with it).
Working...