By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,291 Members | 3,096 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,291 IT Pros & Developers. It's quick & easy.

CLOB.createTemporary throws ClassCastException - fyi

P: n/a
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.physicalConnec tionWithin
(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).
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: 1
Chris,

I have seen this "fenomenon" (ClassCast when getting a tempClob) a lot of times, and have seen some handy solutions to it (some having to do with Log4J-settings, can you believe it, others with OPAQUE-stuff). But I must admit that your solution is by far the most elegant. I am rewriting my code right this instant. Thank you for sharing your code with us.

Kudos for Chris.

Martijn
Jul 9 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.