• Register
0 votes

Problem :

I am getting bellow error while trying to execute  JDBC code
java.sql.sqlexception: operation not allowed after resultset closed
6 5 3
6,930 points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

I think after while(Rs2.next()) you are trying to access something from Rs1. 

But it is already closed.

As you are re executing the statement to get Rs2 from it. Since you didn't close it, I think it is used again.

Further Readings :

9 7 4
38,600 points
0 votes


The issue is with the scheme you retrieve data in getStuff(). Every time you visit getStuff() you gain a fresh ResultSet however you don't close it.

By default, just one ResultSet object per Statement object can be open at the same time. Hence, in case the reading of one ResultSet object is interleaved with the reading of another, each should have been originated by diverse Statement objects. All execution systems in the Statement interface implicitly close a statment's recent ResultSet object in case an open one subsists.

What creates things even worse is the rs from the calling code. It is further executed off-of the statement field however it is not closed.

Bottom line: you have various ResultSet concerning to the same Statement object concurrently unveiled.

A ResultSet object is automatically closed at the time the Statement object that originated it is closed, re-executed, or exercised to fetch the next result from a sequence of multiple results.

I guess after while(rs2.next()) you are attempting to access something from rs1. However, it's meanwhile closed because you reexecuted statement to get rs2 from it. Because you didn't close it, I beleive it's exercised again below.

10 6 4
31,120 points

Related questions

0 votes
1 answer 453 views
Problem : I am updating values using JDBC but getting bellow error java.sql.sqlexception: column count doesn't match value count at row 1
asked Oct 31, 2019 peterlaw 6.9k points
0 votes
1 answer 15 views
Problem: I need help: how to retrieve data from database of a particular user after login in php
asked Mar 19 Wafa Abu Yousef 6.1k points
0 votes
2 answers 445 views
0 votes
1 answer 28 views
I need to know how to return multiple values from a function in Java.
asked Oct 3, 2020 Daniel Anderson 4k points
0 votes
1 answer 12 views
Basically we are trying at the time of registering users in a database table, we need to ensure that every user's email address or username is unique.
asked Sep 26, 2020 Daniel Anderson 4k points
0 votes
1 answer 57 views
Problem: I want to check if the very specific value already exists in the database. I am currently accessing database from the java standalone app using the JDBC my queries for inserting records into the db are working so my setup and the connection are perfectly fine. ... near 'd-f05708071f8f' at line 1 But if I attempt to execute above command in the MySQL command line then it works properly.
asked Aug 3, 2020 Raphael Pacheco 4.9k points
2 votes
1 answer 23 views
Problem: I am beginner to jTable. I have already attached the jTable to JDBC database. But I don’t know how to retrieve them. My requirement is the saved data must be shown if I restart my program but currently it is not working for me. I have ... studentName"); String myshool = myrs.getString("schoolName"); String myjoining = myrs.getString("joiningDate"); } Can somebody solve my problem ?
asked Mar 24, 2020 morrisBson 3.2k points
0 votes
1 answer 299 views
Problem: I have only a little knowledge in MySQL. In MySQL currently I have two tables they are tableA and tableB. I am trying to execute below two queries on the tables: executeQuery(query1)  executeQuery(query2) But I am facing the following unexpected error: “Can not issue data manipulation statements with executeQuery().” I need support from the MySQL expert to fix my above error.
asked Jul 23, 2020 Raphael Pacheco 4.9k points
0 votes
0 answers 3 views
Problem: Hi I am facing this iisue can some one help me? column count doesn't match value count at row 1
asked Mar 20 PkGuy 13.1k points
1 vote
4 answers 7 views
Problem: Hi! Can some one help to solve this problem column count doesn't match value count at row 1 php
asked Mar 20 PkGuy 13.1k points