Java. SQL. SQLException: ORA-00604: recursive SQL Level 1 error, recursive SQL Level 1 error
The following error is reported in the background:
Caused by: java. SQL. SQLException: ORA-00604: recursive SQL Level 1 error
ORA-01000: exceeds the maximum number of opened cursors
ORA-00604: recursive SQL Level 1 error
ORA-01000: exceeds the maximum number of opened cursors
ORA-01000: exceeds the maximum number of opened cursors
Cause:
This error occurs when you use code to execute database commands cyclically (for example, import data to a database or insert data to a database by scheduled tasks), for example, in java
1. Create a Connection
2. Create PreparedStatement cyclically and execute Data Import
3. Disable OracleConnection
When the number of cycles in step 2 is relatively small, the code runs normally. When the number of loops exceeds a certain value (for example, 300), the code will go wrong. Tip:
ORA-01000: exceeds the maximum number of opened cursors
The maximum number of opened cursors in the Oracle database is a fixed value. The default value is 300. When the code reaches the second step, a PreparedStatement in the loop occupies a database cursor, when the number of executed cycles exceeds this threshold, an overflow error occurs.
Solution:
After PreparedStatement is executed in the second loop, you can release this resource under PreparedStatement. close ().
In addition, you can modify the maximum number of database cursors. However, this method does not cure the problem. (Alter system set open_cursors = 1000 scope = both;)