Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting oracle.jdbc.driver.LogicalConnection, need oracle.jdbc.OracleConnection

I am trying to connect to an Oracle database inside a Java application running on WebSphere. I need to be able to create an array descriptor to use in a call to a procedure.

The code looks like this:

Connection conn=null;
ArrayDescriptor arrayDescriptor;
Connection tmpCon = jdbcTemplate.getDataSource().getConnection();
conn =  WSCallHelper.getNativeConnection(tmpCon);
arrayDescriptor = ArrayDescriptor.createDescriptor("t_my_array",conn);
IDs = new oracle.sql.ARRAY(arrayDescriptor, conn, list.toArray());

The line that calls ArrayDescriptor.createDescriptor throws a class cast exception

java.lang.ClassCastException: oracle.jdbc.driver.LogicalConnection incompatible with oracle.jdbc.OracleConnection
    at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:149)
    at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:115)

Walking through this with the debugger, I can see that conn is definitely a oracle.jdbc.driver.LogicalConnection. The problem is I can't actually reference LogicalConnection in my code because that class is not public, so I can't just do something like this:

arrayDescriptor = ArrayDescriptor.createDescriptor("t_my_array",((LogicalConnection)conn).getWrapper());

.

And this:

arrayDescriptor = ArrayDescriptor.createDescriptor("t_my_array",((oracle.jdbc.driver.OracleConnection)conn).getWrapper());

also returns a class cast exception:

java.lang.ClassCastException: oracle.jdbc.driver.LogicalConnection incompatible with oracle.jdbc.driver.OracleConnection

I need to have an OracleConnection object, but I can't seem to get one from the LogicalConnection that gets returned to me. Has anyone ever seen this before? I feel I'm missing something really obvious here, but maybe I just need another cup of coffee...

like image 744
FrustratedWithFormsDesigner Avatar asked Feb 23 '26 20:02

FrustratedWithFormsDesigner


1 Answers

@Alex Poole pointed me in the right direction. Maven was including an Oracle jar, version 10.2.0.1.0, and WebSphere had the same jar, but version 10.2.0.4.0.

After fixing the POM so that the 10.2.0.1.0 version jar didn't get deployed, the problem seems to be resolved.

like image 98
FrustratedWithFormsDesigner Avatar answered Feb 25 '26 08:02

FrustratedWithFormsDesigner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!