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

后端 未结 13 1420
鱼传尺愫
鱼传尺愫 2020-11-22 08:36

I am getting an ORA-01000 SQL exception. So I have some queries related to it.

  1. Are maximum open cursors exactly related to number of JDBC connections, or are t
13条回答
  •  花落未央
    2020-11-22 09:08

    I faced the same problem (ORA-01000) today. I had a for loop in the try{}, to execute a SELECT statement in an Oracle DB many times, (each time changing a parameter), and in the finally{} I had my code to close Resultset, PreparedStatement and Connection as usual. But as soon as I reached a specific amount of loops (1000) I got the Oracle error about too many open cursors.

    Based on the post by Andrew Alcock above, I made changes so that inside the loop, I closed each resultset and each statement after getting the data and before looping again, and that solved the problem.

    Additionaly, the exact same problem occured in another loop of Insert Statements, in another Oracle DB (ORA-01000), this time after 300 statements. Again it was solved in the same way, so either the PreparedStatement or the ResultSet or both, count as open cursors until they are closed.

提交回复
热议问题