This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Stored procedure question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Stored procedure question" Watch "Stored procedure question" New topic
Author

Stored procedure question

Atul Mishra
Ranch Hand

Joined: Jun 08, 2006
Posts: 140
All, I am new to accessing Stored procedures using jdbc, I have a stored procedure which returns multiple resultsets and each result set is stored in a PL?sql table.

How can I retrieve these ?
Any links/code samples please help
Thanks
Leandro Dantas
Greenhorn

Joined: Feb 01, 2007
Posts: 14
http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db2.doc.java/tjvjdmlt.htm

CallableStatement cstmt;
ResultSet rs;
int i;
String s;
...
cstmt.execute(); // Call the stored procedure 1
rs = cstmt.getResultSet(); // Get the first result set 2
while (rs.next()) { // Position the cursor 3
i = rs.getInt(1); // Retrieve current result set value
System.out.println("Value from first result set = " + i);
// Print the value
}
cstmt.getMoreResults(); // Point to the second result set 4a
// and close the first result set
rs = cstmt.getResultSet(); // Get the second result set 4b
while (rs.next()) { // Position the cursor 4c
s = rs.getString(1); // Retrieve current result set value
System.out.println("Value from second result set = " + s);
// Print the value
}
rs.close(); // Close the result set
cstmt.close(); // Close the statement

Best regards.
 
Don't get me started about those stupid light bulbs.
 
subject: Stored procedure question
 
Similar Threads
Stored Procedure + Hibernate + DB2
query for updating
VARBINARY in sp -how-to
stored procedure inside another stored procedure
Help with: java.sql.SQLException: ORA-01008: not all variables bound