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

  • SEARCH
  • Home
  • 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 9101101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:02:03+00:00 2026-06-17T01:02:03+00:00

The below code is showing error: Operation not allowed after ResultSet closed i haven’t

  • 0

The below code is showing error:Operation not allowed after ResultSet closed
i haven’t closed any resultset still it is showing error. i am using one ResultSet inside other ResultSet, does that causing problem??

int n=li10.getSelectedIndex();
    final String n1=(String) dl10.elementAt(n);
    String n2=t52.getText();
    String n3="Select Budget,Count1 FROM User Where U_Name=' "+n2+"'";
    String n4="Select Price From Player_Attributes Where Player_Name='"+n1+"'";
    try{
    Connection con=DriverManager.getConnection("jdbc:mysql://127.0.0.1/BFPL","root","ilovepepsi");
    Statement st=con.createStatement();
    ResultSet rs1=st.executeQuery(n4);
    ResultSet rs=st.executeQuery(n3);
    while(rs1.next()){
    int pr=rs1.getInt("Price");
    while(rs.next()){
    int f=rs.getInt("Budget");
    int f1=rs.getInt("Count1");
    if(f1>0 && pr<f ){
    try{
    Connection con5=DriverManager.getConnection("jdbc:mysql://127.0.0.1/BFPL","root","ilovepepsi");
    PreparedStatement st2=con5.prepareStatement("Update User_Team Set Player"+f1+"=? Where User_Name='"+n2+"'");
    st2.setString(1,n1);
    st2.executeUpdate();
    JOptionPane.showMessageDialog(p13,"Table is updated");
    }
    catch(SQLException ae){
    System.out.println("SQLException:"+ae.getMessage());
    System.out.println("SQLState:"+ae.getSQLState());
    System.out.println("VendorError:"+ae.getErrorCode());
    JOptionPane.showMessageDialog(p13,"Error in submitting data!");
    }
    f1=f1-1;
    f=f-pr;
    try{
    Connection con4=DriverManager.getConnection("jdbc:mysql://127.0.0.1/BFPL","root","ilovepepsi");
    PreparedStatement st1=con4.prepareStatement("Update User Set Budget=? Count1=? Where U_Name='"+n2+"'");
    st1.setInt(1,f);
    st1.setInt(2,f1);
    st1.executeUpdate();
    con4.close();
    JOptionPane.showMessageDialog(p13,"Data is successfully inserted in database");
    }
    catch(SQLException ae){
    System.out.println("SQLException:"+ae.getMessage());
    System.out.println("SQLState:"+ae.getSQLState());
    System.out.println("VendorError:"+ae.getErrorCode());
    JOptionPane.showMessageDialog(p13,"Error in submitting data!");
    }

    }
    else{

    JOptionPane.showMessageDialog(p13,"Either your budget is not sufficient or you have reached maximum limit of buying players");

    }
  • 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-17T01:02:04+00:00Added an answer on June 17, 2026 at 1:02 am

    You can open only one result set per statement. So if you open another one on the same statement, then any previously opened one would be implicitly closed. If you still try to access it, then exactly this exception will be thrown.

    There are basically 2 solutions to your problem:

    1. Create 2 statements on the same connection and let them each open a single result set.

    2. Rewrite and merge the 2 loose SQL queries into a single SQL query returning exactly the desired results, so that you don’t need to create multiple statements. The SQL JOIN clause may come in handy with this.


    Unrelated to the concrete problem, you’ve another major problem in your code. It’s leaking away DB resources. You’re not explicitly closing all so far opened connections, statements and result sets and even not in the finally block. See also How often should Connection, Statement and ResultSet be closed in JDBC?.

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

Sidebar

Related Questions

Below code not work, but it's work fine for jsf1.2. Now the framework is
Below code saying error incorreect syntax near Main INSERT INTO tbl ( 'Week', Main,
The below code give me a foreach error. What appears to be the issue
My application is showing this error below: Data binding directly to a store query
Below code is validating properly.When i first submit the form,it shows the error message,second
I get the below error when running the below code on a controller. Please
I tried below code for cheking SP is alredy exist or not. if not
I am using the below code snippet to allocate memory for 2D array using
I am using below code to compare pass and confirm password text field. Its
I have the int cannot be dereferenced error in the below code where I

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.