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

解决方案 »

  1.   

    这个问题好像不是ORACLE与JAVA组合导致的问题,本来就是ORACLE的SP不能返回游标,而SQLServer的SP可以。你运气不会呀!
      

  2.   

    你如果想利用JAVA可移植的优势,就不应该用存储过程,这样岂不是让自己在数据库上面被限死了!
      

  3.   

    Oracle是不可以返回游标,但是可以作为输出参数来完成的
    CallableStatement cs = conn.prepareCall("{call MyProc(?)}");
    ResultSet rs = (ResultSet)cs.getObject(1);
      

  4.   

    我觉得你的写的好像有问题吧?cs是executeUpdate()还是executeQuery?
      

  5.   

    cs.execute();//
    通过get回来第一个参数的返回值,当然你的存储过程必须写明第一个参数是OUT类型并是一个游标
      

  6.   

    java.sql.Types.后面有游标类型吗?
      

  7.   

    如果你有安装weblogic的话可以参考一下
    D:\bea\wlserver6.1\samples\examples\jdbc\oracle\spcursors.java这个文件,里面大概有一个weblogic的例子。和直接使用Oracle的JDBC比较类似
      

  8.   

    你能具体告诉我怎么写吗?因为我没有安装WEBLOGIC,你可以将spcursors.java发到我的邮箱里吗?[email protected]
    万分感谢你的帮助!
      

  9.   

    Types.OTHER不行!
    你能给我一个存储过程的例子吗?我现在是用包调用过程!
      

  10.   

    数据库定义
    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));
            }