ORA-01000: maximum open cursors exceeded

绿悠悠 发布于 2011/08/15 13:40
阅读 3K+
收藏 0

我的项目运行一会就会报 “ORA-01000: maximum open cursors exceeded” 这样的错误,但是代码中 ResultSet、PreparedStatment 和 Connection 都在 finally 块中关闭了啊,还能是什么问题引起呢?

异常信息如下:

15/07/2011 00:01:06 ERROR [Thread_Validate_1] Validate_Card:name = Thread_Validate_1: Error SQLException : ORA-01000: maximum open cursors exceeded

java.sql.SQLException: ORA-01000: maximum open cursors exceeded

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1039)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1132)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)

对了,使用了 BoneCP 连接池。

使用 BoneCP 的代码如下:

this.config = new BoneCPConfig();
this.config.setJdbcUrl("jdbc:oracle:thin:@127.0.0.1:1521:test");
this.config.setUsername("test");
this.config.setPassword("test");
this.config.setMaxConnectionsPerPartition(6);
this.config.setMinConnectionsPerPartition(2);
this.config.setConnectionTimeout(TimeUnit.MILLISECONDS.convert(60, TimeUnit.MINUTES)); 
this.config.setIdleMaxAge(2);
this.config.setIdleConnectionTestPeriod(1);
this.config.setPartitionCount(1);
this.config.setConnectionTestStatement("select 1 from dual");
this.config.setInitSQL("select 1 from dual");
this.config.setAcquireRetryAttempts(7);
this.config.setAcquireRetryDelay(10000);

加载中
0
曹敏

今天自己写了类似操作Oracle数据库的代码,测试也出现楼主上面提到的问题。在网上搜了一下原因,提到createStatement和prepareStatement代码不要放在循环里边,关闭应该放到fianlly里边,按照statement\connection顺序关闭。我重新改了下自己代码,没问题了。

不知道对楼主有没有帮助,就是自己正好也出现了,就写写。希望写的对楼主解决问题有用!

返回顶部
顶部