A lot of friends in Java development, the use of Oracle database, often encounter a ora-01000:maximumopencursorsexceeded error.
In fact, the reason for this error is mainly caused by code problems.
Ora-01000:maximumopencursorsexceeded.
Represents the maximum number of cursors that have reached a process opening.
The main reason such bugs are easy to appear in Java code is that Java code is actually fairly open to a cursor in the database when executing conn.createstatement () and Conn.preparestatement (). In particular, if your createstatement and preparestatement are in a loop, this problem will be very easy to come by. Because the cursor is constantly open and not closed.
In general, when we write Java code, createstatement and preparestatement should be placed outside the loop, and after using these statment, shut down in time. It is best to shut down statment immediately and call the Close () method after performing a executequery, executeupdate, and so on, if you do not need to use the result set (ResultSet) data.
For the occurrence of ORA-01000 error This situation, simple to increase open_cursors is not a good way, it is only a symptom not a cure. In fact, the hidden trouble in the code has not been lifted.
Moreover, in most cases, open_cursors only need to set a relatively small value, is sufficient to use, unless there are very special requirements.