aspose file tools
The moose likes JDBC and the fly likes How  to  return  resultset  from stored procdure Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "How  to  return  resultset  from stored procdure" Watch "How  to  return  resultset  from stored procdure" New topic
Author

How to return resultset from stored procdure

ven
Greenhorn

Joined: Jul 16, 2001
Posts: 1
Hi All,
My select statement in stored procedure returning multiple
rows. How can I call stored procedure from java using callable statement.
can any body give with simple example both java and sp.
Thanks in Advance
ven
darsh lak
Greenhorn

Joined: Jul 17, 2001
Posts: 1
Use refcursor to return a cursor from storedprocedure
then use getObject(i) and typecast to Resutset
this should solve ur problem
A Agrawal
Ranch Hand

Joined: Jul 13, 2001
Posts: 41
Assuming cstmt is your callable statement variable name and conn is your connection variable name...and GP_FETCH_EISCONTACTS is your stored procdure's name.
try this...
cstmt = conn.prepareCall("{call GP_FETCH_EISCONTACTS (?,?,?)}");
int eid = 599;
String code = "Amit";
cstmt.setInt(1,eid);
cstmt.setString(2,code);
cstmt.registerOutParameter(3,OracleTypes.CURSOR);
intRetVal = cstmt.executeUpdate();
rs=(ResultSet)cstmt.getObject(3);


------------------
Amit Agrawal,
New Delhi, India.


Amit Agrawal,<BR>New Delhi, India.
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6913
"ven",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.


A Convergent Visionary ~ Frank's Punchbarrel Blog ~ LinkedIn profile
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to return resultset from stored procdure
 
Similar Threads
%rowtype mapping in java
stored procedure_array
Array as input to stored procedure.
How to call stored procedure through Hibernate?
How resultset is returned by stored procedure?