目前在做一个Reproting Services项目,通过存储过程中的ref cursor参数返回数据集。在存储过程中只有Open Cursor的语句而没有Close Cursor语句。因为那样的话在报表中就得不到数据集了。
    现在的问题是如果访问量过大就会出现“Ora-01000 maximum open cursors exceeded"的错误,意思是说打开的游标太多了,没有及时关闭。可是我在报表中怎么去关闭游标呢。又不能在存储过程中关闭,真是愁死人了,希望各位大侠帮忙呀。给出个解决方案来。谢谢了

解决方案 »

  1.   

    先看看open_cursors参数设置的多大,可适当增大。
    根本解决还得从程序本身。
      

  2.   

    导致这个错误有可能是程序中用来连接库,执行sql的代码,没有close();
    import java.sql.*;
     2import java.sql.Connection;
     3import java.sql.DriverManager;
     4
     5public class mysqltest {
     6    public static void main(String[] args) {
     7        try{
     8            Class.forName("com.mysql.jdbc.Driver").newInstance();
     9            String url ="jdbc:mysql://localhost:3306/mydb01";
    10            Connection conn= DriverManager.getConnection(url,"root","0000");
    11            Statement stmt=conn.createStatement();
    12            String sql="select * from table1";
    13            ResultSet rs=stmt.executeQuery(sql);
    14
    15            while(rs.next()) {
    16                System.out.print(rs.getInt("CD")+"\t");
    17                System.out.println(rs.getString("NAME"));
    18            }
    19
    20            System.out.println("Done");
    21            rs.close();//有没有把这些代码落下[/b]
    22            stmt.close();//有没有把这些代码落下[/b]
    23            conn.close();//有没有把这些代码落下[/b]
    24           
    25       }catch(Exception e){
    26           e.printStackTrace();
    27       }
    28    }
    29}
    30
      

  3.   

    如果循环执行 查询SQL的话 在每次查询后都要关
      

  4.   

    我是在设计报表的时候调用存储过程,根本就没有“代码”,只是在设计的时候给报表的数据集指定一个存储过程名,并指定参数就可以了,没有写类似open,close的地方,这些工作是由报表服务本身来做的。现在给我的感觉是不知道从哪里下手呀
      

  5.   

    用系统管理员登陆--什么sql开了多少 cursor
    select q.sql_text, o.sid, machine,status,terminal,program, count(*) num_curs
    from v$open_cursor o, v$session s ,v$sql q
    where user_name = 'EGSYS' and o.sid=s.sid and program is null 
    and s.logon_time >= TO_date('2009/01/07 09:00:00','yyyy-mm-dd hh24:mi:ss')--察看什么时间
    and q.hash_value=o.hash_value
    and o.user_name='EGSYS' --系统管理员
    group by o.sid, q.sql_text,machine,status,terminal,program
    order by  num_curs desc;--只能看看到部分, 不行就看看v$open_cursor视图--要不就像一楼说的 设置大点  默认好像是50
      

  6.   

    ORA-01001 invalid cursorCause: Either a host language program call specified an invalid cursor or the value of the MAXOPENCURSORS option in the precompiler command were too small. All cursors must be opened using the OOPEN call before being referenced in any of the following calls: SQL, DESCRIBE, NAME, DEFINE, BIND, EXEC, FETCH, and CLOSE. The Logon Data Area (LDA) must be defined by using OLON or OLOGON. If the LDA is not defined, this message is issued for the following calls: OPEN, COM, CON, ROL, and LOGOFF.Action: Check the erroneous call statement. Specify a correct LDA area or open the cursor as required. If there is no problem with the cursor, it may be necessary to increase the MAXOPENCURSORS option value before precompiling.