Result Set in Java moves the cursor down one row from its current position. A ResultSet cursor is initially positioned before the first row; the first call to the method next makes the first row the current row; the second call makes the second row the current row, and so on.
I was getting "java.sql.SQLException: Exhausted Resultset" error. this is because my query was returning zero records. After adding a check "while (resultSet.next())" before fetching values from the result set helped.