????????????proc.getString(2)?е????2???????????????洢?????е?out?ж????????out????????λ???????proc.getString(1)????????????λ?????proc.getString(3)?????????????ж????????????????????out???????
?????????????б?
????????oracle?洢??????з?????????????з???????????out?????????????б????????????????????????????????????????????????pagkage??.??????????????
????1?? ???????????????£?
????CREATE OR REPLACE PACKAGE TESTPACKAGE  AS
????TYPE Test_CURSOR IS REF CURSOR;
????end TESTPACKAGE;
????2???????洢??????洢???????
????CREATE OR REPLACE PROCEDURE TESTC(p_CURSOR out TESTPACKAGE.Test_CURSOR) IS
????BEGIN
????OPEN p_CURSOR FOR SELECT * FROM HYQ.TESTTB;
????END TESTC;
???????????????????α???????????????????????out ??????????????
??????java????????????????

 

package com.hyq.src;
import java.sql.*;
import java.io.OutputStream;
import java.io.Writer;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import oracle.jdbc.driver.*;
public class TestProcedureTHREE {
public TestProcedureTHREE() {
}
public static void main(String[] args ){
String driver = "oracle.jdbc.driver.OracleDriver";
String strUrl = "jdbc:oracle:thin:@127.0.0.1:1521:hyq";
Statement stmt = null;
ResultSet rs = null;
Connection conn = null;
try {
Class.forName(driver);
conn = DriverManager.getConnection(strUrl?? "hyq"?? "hyq");
CallableStatement proc = null;
proc = conn.prepareCall("{ call hyq.testc(?) }");
proc.registerOutParameter(1??oracle.jdbc.OracleTypes.CURSOR);
proc.execute();
rs = (ResultSet)proc.getObject(1);
while(rs.next())
{
System.out.println("<tr><td>" + rs.getString(1) + "</td><td>"+rs.getString(2)+"</td></tr>");
}
}
catch (SQLException ex2) {
ex2.printStackTrace();
}
catch (Exception ex2) {
ex2.printStackTrace();
}
finally{
try {
if(rs != null){
rs.close();
if(stmt!=null){
stmt.close();
}
if(conn!=null){
conn.close();
}
}
}
catch (SQLException ex1) {
}
}
}
}

???????????????????????????oracle???????????class·????????????