Java issues with Oracle ORA-01000

Source: Internet
Author: User

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 such errors in Java code is:

When Java code executes conn. createstatement () and conn. preparestatement (), 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.

Generally, when writing Java code, both createstatement and preparestatement should be placed outside the loop,

In addition, after using these statment, close them in time. It is best to immediately close statment and call the close () method if you do not need to use resultset data after executing a executequery or executeupdate operation.

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.

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.