Home >Database >Mysql Tutorial >Why Does My Oracle Query Throw a 'java.sql.SQLException: Exhausted ResultSet' Error?
When attempting to execute a query against an Oracle database from within a Websphere connection pool, an error message stating "java.sql.SQLException: Exhausted ResultSet" may appear. This error typically arises when trying to access a column value after the resultset has been processed.
The provided Java code snippet illustrates the issue:
if (rs != null) { while (rs.next()) { count = rs.getInt(1); } count = rs.getInt(1); //this will throw Exhausted resultset }
When accessing a column value after the resultset has been completed, this code snippet retrieves the value successfully in the first iteration (when count = rs.getInt(1)) but fails in subsequent iterations, resulting in the "Exhausted ResultSet" error.
To resolve this issue, ensure that all column values are accessed within the loop that processes the resultset:
if (rs != null) { while (rs.next()) { count = rs.getInt(1); // Add additional code here to access other column values } }
The above is the detailed content of Why Does My Oracle Query Throw a 'java.sql.SQLException: Exhausted ResultSet' Error?. For more information, please follow other related articles on the PHP Chinese website!