Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.sql.SQLException: Exhausted Resultset

Tags:

I get the error java.sql.SQLException: Exhausted ResultSet to run a query against an Oracle database. The connection is via a connection pool defined in Websphere. The code executed is as follows:

if (rs! = null) (     while (rs.next ()) (         count = rs.getInt (1);     ) ) 

I note that the resultset contains data (rs.next ())

Thanks

like image 859
Montse Garcia Avatar asked Aug 17 '10 11:08

Montse Garcia


People also ask

What is Java SQL SQLException exhausted ResultSet?

java.sql.SQLException: Exhausted Resultset. It is thrown when cursor does not point to any row in ResultSet's object. It may be thrown when rs. getString("COLUMN_NAME") is called after iterating on ResultSet object.

What is meant by exhausted ResultSet?

Exhausted Resultset means the the while loop that you have placed after ResultSet rs is terminated by you, and thus the ResultSet is exhausted.


2 Answers

I've seen this error while trying to access a column value after processing the resultset.

if (rs != null) {   while (rs.next()) {     count = rs.getInt(1);   }   count = rs.getInt(1); //this will throw Exhausted resultset } 

Hope this will help you :)

like image 81
sourcerebels Avatar answered Oct 07 '22 00:10

sourcerebels


Try this:

if (rs != null && rs.first()) {     do {         count = rs.getInt(1);     } while (rs.next()); } 
like image 42
cadrian Avatar answered Oct 07 '22 00:10

cadrian