aspose file tools*
The moose likes JDBC and the fly likes passing array of objects from oracle stored procedure to java ...Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "passing array of objects from oracle stored procedure to java ...Error" Watch "passing array of objects from oracle stored procedure to java ...Error" New topic
Author

passing array of objects from oracle stored procedure to java ...Error

Raj Sikka
Ranch Hand

Joined: Apr 11, 2003
Posts: 34
Hi ,
i have written a oracle procedure and a java file.
my oracle procedure returns an array to java.
but while collecting the array in java it says
"java.sql.SQLException: Fail to construct descriptor: Unable to resolve type: "SVM_220.t_id"
"
please have a look at the code below .
please help me out in solving this problem.
Thanks and Regards,
Srikanth
------------------------------------------------
Following is the oracle package.
------------------------------------------------
CREATE OR REPLACE PACKAGE SimplePackage AS
TYPE STLISTOBJ as object(ID NUMBER(10));
TYPE t_id is TABLE of STLISTOBJ;
PROCEDURE proc1
(
in_nu IN NUMBER,
o_id OUT t_id
);
END SimplePackage;
/
CREATE OR REPLACE PACKAGE BODY SimplePackage AS
PROCEDURE proc1 (in_nu IN NUMBER,o_id OUT t_id) AS
BEGIN
o_id(1):= STLISTOBJ(200);
o_id(2) := STLISTOBJ(201);
END proc1;
END SimplePackage;
/
-----------------------------------------------
Here is my java program ..
------------------------------------------------
import java.sql.*;
import java.util.*;
import oracle.jdbc.driver.*;
import oracle.sql.*;
import oracle.sql.ArrayDescriptor.*;
import java.sql.SQLException;
public class getArray extends MultipleResultsets
{
public static void main(String args[]) {
try{
Vector errorObjectVector = new Vector();
System.out.println("setting up connection");
Connection connection = setupConnection();
CallableStatement myCallable =
connection.prepareCall("{CALL SimplePackage.proc1(?,?)}");
myCallable.setInt(1,1);
myCallable.registerOutParameter(2,OracleTypes.ARRAY,"t_id");
myCallable.execute();
ARRAY ObjectArray = (oracle.sql.ARRAY)myCallable.getObject(1);
ResultSet myResultSet = ObjectArray.getResultSet();
while (myResultSet.next())
{
oracle.sql.STRUCT eachObject = (oracle.sql.STRUCT)myResultSet.getObject(2);
errorObjectVector.addElement(eachObject);
}
int vectorSize = errorObjectVector.size();
System.out.println("Size of Vector:"+vectorSize);
connection.close();
}
catch (SQLException e) {
System.out.println("SQL EXE:"+e);
}
catch (Exception ex) {
System.out.println("EXE:"+ex);
}
}
}
-------------------------------------------------
Error getting while execution of my java file.
java.sql.SQLException: Fail to construct descriptor: Unable to resolve type: "SVM_220.t_id"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: passing array of objects from oracle stored procedure to java ...Error