Java Development, when using Oracle database, often encounter a ORA-01000: maximum open cursors exceeded. Error.
In fact, the cause of this error is mainly caused by code problems.
Ora-01000: maximum open cursors exceeded.
Indicates that the maximum number of opened cursors has been reached for a process.
The main cause of such errors in Java code is:
When Java code executes conn. createstatement () and conn. preparestatement (), it is equivalent to opening a cursor in the database.
In particular, if your createstatement and preparestatement are in a loop, this issue is very likely to occur.
Because the cursor is always open and not closed.
Generally, when writing Java code, both createstatement and preparestatement should be placed outside the loop,
In addition, after using these statment, close them in time. It is best to immediately close statment and call the close () method if you do not need to use resultset data after executing a executequery or executeupdate operation.
For the case of ORA-01000 errors, simply increase open_cursors is not a good way, it is just a temporary cure. In fact, the hidden risks in the Code have not been removed.
In most cases, open_cursors only needs to set a small value, which is enough unless there are special requirements.