Link to home
Start Free TrialLog in
Avatar of Web_Admin
Web_Admin

asked on

Exhausted Resultset

Hello experts,

I have this code that sometimes throws : java.sql.SQLException: Exhausted Resultset. could you please how i can fix this
this.con = connectToDB();
            if (con != null ){
            String query = ""
            Statement statement = this.con.createStatement();
            ResultSet resultSet = statement.executeQuery(query);

            searchResult = new Vector();
            int i = 0;
            if (resultSet != null) {
                while (resultSet.next()) {
                    System.out.println("i"+i+1);
                    String[] name = resultSet.getString("NAME").split(",");
                    Faculty facutlty = new Faculty(
                            resultSet.getString("PERSON_UID"),
                            name[1]+" "+name[0],
                            resultSet.getString("GOBTPAC_LDAP_USER"),
                            resultSet.getString("SYRREIN_INTEREST"));
                    searchResult.add(facutlty);
                }

            }

            statement.close();
            resultSet.close();
            closeConnection(con);
            }
            return searchResult;
        } catch (SQLException sqlException) {
            this.logger.logLines(this.formatter.format(this.today) + ":searchFacultyInterest:Failed");
            this.logger.logLines(this.formatter.format(this.today) + ":SQLException:" + sqlException.getMessage());
            closeConnection(this.con);
            return null;
        } catch (NullPointerException nullPointerException) {
            this.logger.logLines(this.formatter.format(this.today) + ":searchFacultyInterest:Failed");
            this.logger.logLines(this.formatter.format(this.today) + ":NullPointerException:" + nullPointerException.getMessage());
            closeConnection(this.con);
            return null;
        }

Open in new window

Avatar of Web_Admin
Web_Admin

ASKER

The exception happened when a pop is opened and another page is loaded @ the same time this page is refreshed
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The query is empty:

>>
           String query = ""
            Statement statement = this.con.createStatement();
            ResultSet resultSet = statement.executeQuery(query); //  'query' is an empty String
>>
it works Thanx object
How can it work with an empty query?
The question is more how an empty query could possibly throw that exception?
i have the query in the code but make it empty here becuase it complex query n might reveal our db structure .. i have it all work now Thanx