JDBC code to access a REFCURSOR.
- By Satya Komatineni
- June 24, 2001
Java Primer
A JSP Architecture for Oracle Stored Procedures
by Satya Komatineni
Listing 1. JDBC code to access a REFCURSOR.
// Specify your stored procedure
// '?' is a place holder for REFCURSOR variable
CallableStatement stmt = con.prepareCall(
"{call pkg_book_info.SpGetAuthors(?)}");
// Bind the '?', the first argument, to an Oracle CURSOR
stmt.registerOutParameter(1,OracleTypes.CURSOR);
stmt.execute();
// Type cast the return to a ResultSet
ResultSet rs = (ResultSet)stmt.getObject(1);
// process the result set as usual after that
.......
finally
{
if (rs != null) rs.close();
if (stmt != null) stmt.close();
if (con !=null) con.close();
}