The maximum cursors that Java encounters with Oracle exceed the problem and how to solve it

Source: Internet
Author: User
Tags oracle database

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.

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.