How can I get data from multiple ResultSets?
With certain database systems, a stored procedure can return multiple result sets, multiple update counts, or some combination of both. Also, if you are providing a user with the ability to enter any SQL statement, you don’t know if you are going to get a ResultSet or an update count back from each statement, without analyzing the contents. The Statement.execute() method helps in these cases.Method Statement.execute() returns a boolean to tell you the type of response: true indicates next result is a ResultSet,Use Statement.getResultSet() to get the ResultSet false indicates next result is an update count Use Statement.getUpdateCount() to get the update count false also indicates no more results Update count is -1 when no more results (usually 0 or positive). After processing each response, you use Statement.getMoreResults() to check for more results, again returning a boolean.