• Register
0 votes
65 views

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

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

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.

10 6 4
31,120 points

Related questions

0 votes
1 answer 279 views
279 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 431 views
431 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 16 views