ClassCast Exception at oracle.sql.BLOB.createTemporary
posted 4 years ago
I am facing a problem that when I am trying to open a temporary BLOB, I am getting a ClassCastException. Below is a part of stack trace:
I am using Weblogic 10.3.4.0 with Jrocket 1.6 Update 24 in my JAVA_HOME.
Initially I thought this is a JDBC driver problem, then I tried with ojdbc14.jar, ojdbc5.jar, ojdbc6.jar but same result.
With more googling I found some other reasons like
Problem which seems to be that despite the fact that method BLOB.createTemporary takes a java.sql.Connection object as a parameter, it only works if the Connection is an oracle.jdbc.driver.OracleConnection object. If it's not an oracle.jdbc.driver.OracleConnection, then I get a ClassCastException.
I also found out that the problem happens because when I run my code in Weblogic and get the database connection via a DataSource object that I lookup via JNDI, the connection is not a real OracleConnection object, but an object that wraps the real OracleConnection.
Now the question is how do I solve this? In My DataSource->Connection Pool-> I have unchecked the "Wrap Data Types" and it still it doesn't work.
I would love to paste the code of how I am opening the Connection to be more understandable but due to my Company policy I cannot. Hope you all understand.
Feel free to ask me whatever details you want, but need a urgent solution for this.
"History would be kind to me, for I intend to write it."