PreparedStatement连续赋值未关闭:ORA-01000: maximum open cursors exceeded

问题代码:

for循环中调用一个方法,方法大致如下:
preparedstatement ps = null;

String sql1 = ".....";
ps= connection.preparestatement(sql1);
ps.executequery();

String sql2 = "......";
ps= connection.preparestatement(sql2);
ps.executequery();

String sql3 = "......";
ps= connection.preparestatement(sql3);
ps.executequery();

解决办法:

preparedstatement ps = null;

String sql1 = ".....";
ps= connection.preparestatement(sql1);
ps.executequery();
ps.close();

String sql2 = "......";
ps= connection.preparestatement(sql2);
ps.executequery();
ps.close();

String sql3 = "......";
ps= connection.preparestatement(sql3);
ps.executequery();
ps.close();

 查询Oracle数据库会话最大游标数:

SQL> show parameter open_cursors;
NAME                  TYPE        VALUE
--------------------- ----------- -----------
open_cursors     integer     1500

 

 

你可能感兴趣的:(PreparedStatement连续赋值未关闭:ORA-01000: maximum open cursors exceeded)