JDBC code to access a REFCURSOR.

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

// Type cast the return to a ResultSet
ResultSet rs = (ResultSet)stmt.getObject(1);

// process the result set as usual after that
    if (rs != null) rs.close();
    if (stmt != null) stmt.close();
    if (con !=null) con.close();