Java. SQL. SQLException: ORA-00604: recursive SQL Level 1 error, recursive SQL Level 1 error

Source: Internet
Author: User

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;)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.