Oracle cursor problems (ORA-01000: maximumopencursorsexceeded)

Source: Internet
Author: User
Tags oracle cursor
Today, Oracle suddenly throws an exception: maximumopencursorsexceeded can be seen from the literal meaning that it is caused by excessive opening of the cursor and not being properly closed

Today, Oracle suddenly throws an exception: maximum open cursors exceeded can be seen from the literal meaning that it is caused by too many opened cursors and not properly closed

Today, Oracle suddenly throws an exception: maximum open cursors exceeded
It can be seen from the literal meaning that the maximum number of connections opened by the system's default cursor is exceeded because the cursor is too open and is not properly closed.
But it is not a simple task to find out which line of code has a problem. Tens of thousands of lines of code are not actually blown out.
This is something that people usually need to pay more attention to during development. Otherwise, they will wait until the code is finally submitted.
Suddenly, it was still a blow to people.

Considerations for using Oracle databases in Java Development
Many friends in 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 this error is that the Java code is executing conn. createStatement () and conn. when prepareStatement () is used, 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.

In general, when writing Java code, both createStatement and prepareStatement should be placed outside the loop and closed in time after these Statment are used. It is best to disable Statment immediately after executing executeQuery, executeUpdate, and so on without using the ResultSet data.

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.

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.