I'm having an issue attempting to create a temporary CLOB in Java. When I use a connection from apache's connection pool, I get a casting exception from Java (see below)
java.lang.ClassCastException: org.apache.commons.dbcp.PoolableConnection
at oracle.sql.CLOB.createTemporary(CLOB.java:754)
at oracle.sql.CLOB.createTemporary(CLOB.java:715)
When I make my own connection using DriverManager, I do not have any problems passing the connection object to the createTemporary() method of the oracle.sql.CLOB object.
e.g.
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection(url, username,password);
if I use this connection, I can create the temporary clob with no problem. I've attempted to use the following bit of code I have found in other examples to pull off any wrapper that apache may be adding to the connection object:
Connection oracleConnection = conn;
if (conn instanceof org.apache.commons.dbcp.DelegatingConnection) {
// This returns a org.apache.commons.dbcp.PoolableConnection
Connection pc = ((org.apache.commons.dbcp.DelegatingConnection)conn).getDelegate();
// The PoolableConnection is a DelegatingConnection itself - get the delegate (the Oracle connection)
oracleConnection = ((org.apache.commons.dbcp.DelegatingConnection)conn).getDelegate();
}
This still doesn't work. When using the above code, I get the same exception albeit in a different form:
java.lang.ClassCastException: oracle.jdbc.driver.T4CConnection
I saw a posting in this forum about this, but none of the information within seems to help/work:
(
857366
If anyone can help shed light on this problem, it would be greatly apprecaited.