The moose likes JDBC and the fly likes does a procedure returns cursor, if so, how to hadle that in java Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "does a procedure returns cursor, if so, how to hadle that in java" Watch "does a procedure returns cursor, if so, how to hadle that in java" New topic
Author

does a procedure returns cursor, if so, how to hadle that in java

Praveen palukuri
Ranch Hand

Joined: Feb 10, 2005
Posts: 65
hi,
can we send a cursor from procedure. if so, how to handle that cursor in java. please help me.

Thank u.
Sujith Kanaparthi
Ranch Hand

Joined: Sep 04, 2005
Posts: 45
Hi Praveen,

A cursor can be used as an out parameter in a procedure.If you want that cursor to be handled in Java then use CallableStatement.

ArrayList cursor1 = new ArrayList();
CallableStatement cst = connection.prepareCall("{call YourProc(?,?)}");
cst.setString(1,in_param);
cst.registerOutParameter(2,oracle.jdbc.driver.OracleTypes.CURSOR);
cst.execute();
cursor1 =(ResultSet)cst.getObject(2);

Where YourProc as one in param and one out param which is a cursor and store that cursor in an arraylist to use the data available in it

Regards,
Sujith
Praveen palukuri
Ranch Hand

Joined: Feb 10, 2005
Posts: 65
thank u sujith,
Here i'm using SqlServer. in this i couldn't find any datatype like cursor. so would u please tell me how to achieve using sqlserver
Sujith Kanaparthi
Ranch Hand

Joined: Sep 04, 2005
Posts: 45
Here i'm using SqlServer.

Sorry Praveen I have never worked on sql server

Regards,
Sujith
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: does a procedure returns cursor, if so, how to hadle that in java
 
Similar Threads
Resultset in Java using Oracle
pass a cursor between databases
Stored Procedures Returning a Cursor
Calling Oracle Stored Procedure which has parameter as CURSOR
How can we call a stored procedure from java file