File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class Cast exception in oracle.sql.ArrayDescriptor

 
Raka Sheth
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1141
1
Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 144
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic