摘自:bea/docs61/oracle/advanced.html
In your Java code, you'll construct CallableStatements with the stored procedures and register the output parameter as data type java.sql.Types.OTHER. When you retrieve the data into a ResultSet, use the output parameter index as an argument for the getResultSet() method.
weblogic.jdbc.oci.CallableStatement cstmt =
(weblogic.jdbc.oci.CallableStatement)conn.prepareCall(
"begin
OPEN ? " +
"FOR select * from emp;
end;
");
cstmt.registerOutParameter(1, java.sql.Types.OTHER);
cstmt.execute();
ResultSet rs = cstmt.getResultSet(1);
printResultSet(rs);
rs.close();
cstmt.close();
weblogic.jdbc.oci.CallableStatement cstmt2 =
(weblogic.jdbc.oci.CallableStatement)conn.prepareCall(
"begin
single_cursor(?, ?);
end;
");
cstmt2.registerOutParameter(1, java.sql.Types.OTHER);
cstmt2.setInt(2, 1);
cstmt2.execute();
rs = cstmt2.getResultSet(1);
printResultSet(rs);
cstmt2.setInt(2, 2);
cstmt2.execute();
rs = cstmt2.getResultSet(1);}
printResultSet(rs);
cstmt2.setInt(2, 3);
cstmt2.execute();
rs = cstmt2.getResultSet(1);
printResultSet(rs);
cstmt2.close();
weblogic.jdbc.oci.CallableStatement cstmt3 =
(weblogic.jdbc.oci.CallableStatement)conn.prepareCall(
"begin
multi_cursor(?, ?, ?);
end;
");
cstmt3.registerOutParameter(1, java.sql.Types.OTHER);
cstmt3.registerOutParameter(2, java.sql.Types.OTHER);
cstmt3.registerOutParameter(3, java.sql.Types.OTHER);
cstmt3.execute();
ResultSet rs1 = cstmt3.getResultSet(1);
ResultSet rs2 = cstmt3.getResultSet(2);
ResultSet rs3 = cstmt3.getResultSet(3);