java.lang.ClassCastException: com.ibm.ws.rsadapter.jdbc.WSJdbcCallableStatement incompatible with oracle.jdbc.OracleCallableStatement
Websphere 6.1.0.17 ND
JEE1.4
Oracle 10G
Setup
jdbc provider and datasource for oracle correctly, tested connection and its working fine on admin console.
In my application, lookup datasource to get connection, then have a call to the database connection on a stored function in oracle. It returns a REFCURSOR so my
java line to return the result set is:
result = ((OracleCallableStatement)cs).getCursor(1);
This gives me the exception above.
i have been searching for solutions on this problem for nearly a day now and found one:
Error on datasource:
You can't count on the implmentation of the CallableStatement interface being the Oracle version, even though your underlying database is Oracle. When you use a WebSphere Data Source, neither the connection nor the objects it creates will cast to Oracle objects.
Because of these issues, IBM has provided a way to get at the "native" (in this case, Oracle) DataBase connection, and consequently at the native objects it creates. The help is in the form of the com.ibm.ws.rsadapter.jdbc.WSJdbcUtil class, which is in the WebSphere class path. Just use it's getNativeConnection method to get the underlying Oracle connection, and then the CallableStatement you produce from it will cast correctly. Example:
connection = (Connection) WSJdbcUtil.getNativeConnection((WSJdbcConnection)dataSource.getConnection());
OracleCallableStatement ocstmt = (OracleCallableStatement) connection.prepareCall(sql);
i do not want to have WAS libraries in my project though.
This jdbc call works fine locally, only a problem when i deploy my application on websphere.
is this a websphere configuration issue i am missing where i can change the implementation name for my jdbc provider or can i not use oracle calls whatsoever?
Thanks,
Shane.