• Register
0 votes
57 views

Problem :

I am getting bellow error while trying to execute  JDBC code
java.sql.sqlexception: operation not allowed after resultset closed
 
6.9k points

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 :

36.1k points
0 votes

Solution:

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.

15.9k points
edited by

Related questions

0 votes
1 answer 203 views
203 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 284 views
284 views
Problem : I am getting bellow error while I try to connect MySql database with Java using connector 8.0.11 java.sql.sqlnontransientconnectionexception: public key retrieval is not allowed
asked Oct 19, 2019 peterlaw 6.9k points
0 votes
1 answer 5 views
5 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 4 days ago Raphael Pacheco 2.6k points
2 votes
1 answer 13 views
13 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 morrisBson 3.2k points
0 votes
1 answer 4 views