What you wanna do ?You could just write as "Select * from tempTable " and could get the resultset in jdbc levelAnyway, if this way is blocked, try to modified your stored procedure to fucntion, and I am sure it will solve the problem
调试欢乐多
CallableStatement cs = conn.prepareCall("{call MyProc(?)}");
ResultSet rs = (ResultSet)cs.getObject(1);
通过get回来第一个参数的返回值,当然你的存储过程必须写明第一个参数是OUT类型并是一个游标
D:\bea\wlserver6.1\samples\examples\jdbc\oracle\spcursors.java这个文件,里面大概有一个weblogic的例子。和直接使用Oracle的JDBC比较类似
万分感谢你的帮助!
你能给我一个存储过程的例子吗?我现在是用包调用过程!
CREATE TABLE EMP (
ID INT NOT NULL,
NAME VARCHAR2 (100),
primary key (ID)
) ;
create or replace package
curs_types as
type EmpCurType is REF CURSOR RETURN emp%ROWTYPE;
end curs_types;CREATE OR REPLACE procedure
single_cursor(curs1 IN OUT curs_types.EmpCurType) AS
BEGIN
OPEN curs1 FOR SELECT * FROM emp;
END single_cursor;程序:
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:a/a@localhost:1521:chdw");
CallableStatement call = conn.prepareCall("{call single_cursor(?)}");
call.registerOutParameter(1,oracle.jdbc.driver.OracleTypes.CURSOR);
call.execute();
ResultSet rs = (ResultSet)call.getObject(1);
while(rs.next()) {
System.out.println(rs.getString(1) + ":" + rs.getString(2));
}