Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8438519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:44:28+00:00 2026-06-10T07:44:28+00:00

I use loops in my java code to insert rows into my database. Then,

  • 0

I use loops in my java code to insert rows into my database. Then, I got the error –

ORA-01000: maximum open cursors exceeded

I searched a little and saw that closing my prepared statements or statements after adding each row helps to get rid of the error.

But, I need to understand –

  1. what are cursors ?
  2. Can i change the number of cursors ? If yes, is it a good thing to do ?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:44:30+00:00Added an answer on June 10, 2026 at 7:44 am

    This link will will explain you what a cursor is and how it works.

    Yes you can change the maximum number of cursors on Oracle using the following statement:
    ALTER SYSTEM SET OPEN_CURSORS=1337 SID='*' SCOPE=BOTH;

    But you should do that just if really needed. What you really should do is handle resultset and statements correctly, and ensure that you always close them. This should typically be done in a try/finally statement.

    If you forget to close these, open cursors will leak until you reach the maximum limit (which comes very quickly), and subsequent requests won’t work (this is the case for you).

    You could edit your question and add some code so that we can show you some hint about how and where your may close the resultset and statement properly.

    This is typical usage:

    Statement stmt;
    try {
       stmt = con.createStatement();
       // do something with the statement
    } catch (SQLException e) {
       LOG.error("SQL error", e);
    } finally {
       try { if (stmt != null) stmt.close(); } catch (SQLException se) { LOG.error("Error closing the statement", se); }
       // if using Apache utils you could do
       // IOUtils.closeQuietly(stmt);
    }
    

    It is the same with resultset. Depending on the version of Java you’re using you could use the try-with-resources idiom.

    try (Statement stmt = con.createStatement()) {
       // do something with the statement
    } catch(SQLException e) {
       LOG.error("SQL error", e);
    }
    

    Java will take care of closing the statement at the end of the try block, since Statement implements the AutoCloseable interface.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got some code which I use to loop through the properties of certain
I recently came across some Java code that simply put some strings into a
I am generating Java code on the fly which will then be compiled and
This is my first attempt to inline Java code in Perl. We cannot use
In Java, I'm able to use for-loops to iterate over ArrayLists or Iterables. In
I'm trying to re-use a Java generic collection I wrote, looks a lot like
I use a loop to load images into an NSMutableArray . Each iteration loads
I need to create a porting software that will convert Java code to C#
I have the following code which uses nested for-each loops to traverse two ArrayList
In some old Java code, I found a class that contains a lot of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.