Sunday, June 27, 2010

Exhausted ResultSet

Hi, if you ever encounter this kind of error

java.sql.SQLException: Exhausted Resultset
at oracle.jdbc.dbaccess.DBError.throwSqlException(
at oracle.jdbc.dbaccess.DBError.throwSqlException(
at oracle.jdbc.dbaccess.DBError.throwSqlException(
at oracle.jdbc.driver.OracleStatement.prepare_for_new_get(
at oracle.jdbc.driver.OracleStatement.getIntValue(
at oracle.jdbc.driver.OracleResultSetImpl.getInt(
at oracle.jdbc.driver.OracleResultSet.getInt(

you might guessed that this error happen when you trying to access a resultset which already being closed or never been advanced to the first record, but you very certain that the statement is never been closed or always advanced to the first record and still these kind of error spitting out in your log or console, you might wanna check if the same statement object had been re-executed. In my case another thread executing the same statement object, thus the previous resultset is reset.
  1. thread A is executing the statement and get the resultset X
  2. thread A advance the resultset X by calling
  3. thread B is executing the statement and get the resultset Y
  4. thread A try to call X.getString("some_field") => spit the error
  5. thread B advance the resultset Y by calling
  6. thread B try to call Y.getString("some_field") => working fine

took me whole night figure this one out, should have read the spec earlier, stupid me...


mahesh krishna said...

Great help thank you, I was stuck with same problem.

Junaid Rana said...
This comment has been removed by the author.
Junaid Rana said...

Thankx Man.....!!
But my problem is still there .I am using only one resultset and i do check next() and with out next() both........!!
Plz sort this out.....!!

Anonymous said...

Same issue am facing.. But I couldn't understand how you resolved the issue and what is the problem in multi threaded enviorment.. Can you detail it?