File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Websphere and the fly likes java.lang.ClassCastException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "java.lang.ClassCastException" Watch "java.lang.ClassCastException" New topic
Author

java.lang.ClassCastException

BalaKishore Pamarti
Greenhorn

Joined: Jul 26, 2005
Posts: 5
Am trying to read the pl/sql index-by table returned as a OUT parameter from a stored procedure. When I am trying to cast CallableStatment to OracleCallableStatement its throwing an exception (java.lang.ClassCastException: com.ibm.ws.rsadapter.jdbc.WSJdbcCallableStatement). Am I missing something here...Am using WAS 6.0 and Oracle 9i ...here is my code...

...
...

connection = (Connection) datasource.getConnection();

OracleCallableStatement ocstmt = (OracleCallableStatement) connection.prepareCall(sql);

ocstmt.registerIndexTableOutParameter(1, maxTablLength, OracleTypes.VARCHAR, eleMaxLen);

boolean flag = ocstmt.execute();
...
...


TIA
[ October 29, 2007: Message edited by: BalaKishore Pamarti ]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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:



Merrill
Consultant, Sima Solutions
BalaKishore Pamarti
Greenhorn

Joined: Jul 26, 2005
Posts: 5
Merrill,

thanks a bunch!!! ClassCastException disappeared...

I am trying to read a pl/sql index-by table (associative array). When I try to register the OUT parameter returned from the stored procedure by saying



This didnt work as this only works for OCI drivers and I am using Oracle thin drivers... then I tried...



even this didnt work...

My question is can we read a pl/sql table in java using oracle thin drivers ??? if yes can you post an example..

regards,
bala

Originally posted by Merrill Higginson:
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:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.ClassCastException