aspose file tools*
The moose likes JDBC and the fly likes Class Cast exception in oracle.sql.ArrayDescriptor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Class Cast exception in oracle.sql.ArrayDescriptor" Watch "Class Cast exception in oracle.sql.ArrayDescriptor" New topic
Author

Class Cast exception in oracle.sql.ArrayDescriptor

Raka Sheth
Greenhorn

Joined: Aug 08, 2006
Posts: 1
Hi All
We are using Oracle Types to pass the list of data to store procedure.We are getting class cast exception while using the connection pool of websphere .FOllowing is the code
connection=myDatasource.getConnection();
cs = connection.prepareCall("{call temp_list(?)}");
System.out.println("Prepare statement is formed");
oracle.sql.ArrayDescriptor descrip =
oracle.sql.ArrayDescriptor.createDescriptor("MY_LIST",connection);
oracle.sql.ARRAY a = new oracle.sql.ARRAY(descrip, connection, s);
cs.setArray(1,a);
cs.execute();

We are getting class cats exception at following line
oracle.sql.ArrayDescriptor descrip =
oracle.sql.ArrayDescriptor.createDescriptor("MY_LIST",connection);


Please help me in resolving this issue
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1132

Raka,
The connection you are obtaining here:

Cannot be used here:

You need an "OracleConnection".

I don't use WebSphere, so I don't know if it is possible to obtain an "OracleConnection".

Good Luck,
Avi.
Arvind Sampath
Ranch Hand

Joined: May 11, 2005
Posts: 144
As Avi said, the createDescriptor() method requires that your connection be an 'OracleConnection'. Internally, the createDescriptor() method *casts* your connection object to 'OracleConnection'. We faced the same problem in Weblogic 5.1. Due to time & other constraints we had no other option but to use a *direct* connection, using thin driver, instead of a Connection Pool. Try using the direct connection until you find a permanent solution.

oracle.sql.ARRAY a = new oracle.sql.ARRAY(descrip, connection, s);
cs.setArray(1,a);


I guess this is not the correct way of passing arrays. You may have to use the cs.setARRAY(1,a) method. This method is part of the OracleCallableStatement class. So you have to cast your CallableStatement to OracleCallableStatement like this



Pls let us know your progress in this.


Arvind
 
 
subject: Class Cast exception in oracle.sql.ArrayDescriptor