现在的位置: 首页 > 综合 > 正文

关于ORA-01000: maximum open cursors exceeded 在Websphere里

2013年08月12日 ⁄ 综合 ⁄ 共 1256字 ⁄ 字号 评论关闭
网上有很多,这边备忘一下。

ORA-01000 这个参数决定一个SESSION的最大打开CURSOR的个数.
可能是异常中断而没有CLOSE,或程序写嘚有问题,或者确实有这么多的CUSOR同时在应用.

 
首先查DB的参数,
       select value
     from v$parameter
     where name = 'open_cursors'
    建议大应用至少1000 .
 
然后,查
           select o.sid, osuser, machine, count(*) num_curs
     from v$open_cursor o, v$session s
     where user_name = 'username' and o.sid=s.sid
     group by o.sid, osuser, machine
     order by num_curs desc;
 
里面肯定有接近 'open_cursors' 的 session , 得到SID.
最后,查看是这些'open_cursors' 都是哪些SQL.
           select q.sql_text
     from v$open_cursor o, v$sql q
     where q.hash_value=o.hash_value and o.sid = XXXXX;
 
现在应该可以定位到那个页面或MODULE导致这个的问题.

Websphere里有个参数Statement cache size ,也是用来缓存的。
看是否大与Oracle的设置。

  • In WebSphere Application Server V5, navigate to the data source in the Admin Console. The Statement cache size appears on the main data source configuration panel.
  • In WebSphere Application Server V6, navigate to the data source in the Admin Console. Under Additional Properties, select WebSphere Application Server data source properties. The first property listed on the resulting screen is the Statement cache size.

另一个也可以设置cursor_sharing = force, 不过这个要看具体环境了。

程序问题,比如:
Java代码在执行conn.createStatement()和conn.prepareStatement()的时候,实际上都是相当与在数据库中 打开了一个cursor。尤其是,如果你的createStatement和prepareStatement是在一个循环里面的话,就会非常容易出现这 个问题。因为游标一直在不停的打开,而且没有关闭。

 
还看到ITPUB上一例是存储空间的问题, 关键还是找到是哪些SQL OPEN 了CURSOR,然后对症下药。

 

抱歉!评论已关闭.