Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ClassCastException ArrayDescriptor SructDescriptor

807606Mar 26 2007
Hi,

I have problem with calling stored procedure in oracle.

One of the IN parameters of the procedure is Array, and when I try to call this procedure I get error:
java.lang.ClassCastException: oracle.sql.StructDescriptor cannot be cast to oracle.sql.ArrayDescriptor

Code in PL/SQL:

CREATE OR REPLACE
type A_TYPE as OBJECT (
firstName varchar2(100),
surname varchar2(100)
);

CREATE OR REPLACE
type A_TYPE_ARRAY is table of A_TYPE;

Code in java:

String function ="xxxxxxxxxx";
OracleCallableStatement cstmt = (OracleCallableStatement)conn.prepareCall(funkcion);
OracleConnection conn = (OracleConnection)DriverManager.getConnection
("jdbc:oracle:thin:@xxxx:1521:xxxxx", "xxx", "xxx");

Object[] atr = new Object[];
StructDescriptor structdesc = StructDescriptor.createDescriptor("A_TYPE", conn);
STRUCT struct = new STRUCT(structdesc, conn, atr);

ArrayDescriptor arrayDesc = ArrayDescriptor.createDescriptor("A_TYPE_ARRAY", conn);
ARRAY array = new ARRAY(arrayDesc, conn, struct);

cstmt.setArray(1, array);
cstmt.execute();

In line where I trying to make arrayDesc I get error:
Exception occurred during event dispatching:
java.lang.ClassCastException: oracle.sql.StructDescriptor cannot be cast to oracle.sql.ArrayDescriptor
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:112)

Can some tell me what causes this problem?

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 23 2007
Added on Mar 26 2007
0 comments
1,229 views