ResultSet

A ResultSet contains the set of rows that make up the result of a query. A ResultSet object is returned when executeQuery() is invoked on a Statement created for a SELECT statement. The ResultSet object must be closed when it is no longer needed. A ResultSet object is returned even if no rows were found for the query.

The ResultSet object contains methods that allow you to iterate over the rows of the query result. A ResultSet object can be iterated over only once. The hasNext() method is used to check if there is a row that can be retrieved. The next() method is used to retrieve the next row object of the result.