471,084 Members | 1,034 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,084 software developers and data experts.

CLOB.createTemporary throws ClassCastException - fyi

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
1 11147
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.

Similar topics

reply views Thread by freak | last post: by
3 posts views Thread by Jon-Paul Dobson | last post: by
5 posts views Thread by Casper B | last post: by
5 posts views Thread by gimme_this_gimme_that | last post: by
3 posts views Thread by gupta.harika | last post: by
8 posts views Thread by gimme_this_gimme_that | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.