After a query is executed, you can use the next() method of the ResultSet object to traverse the results.
This method can traverse the result set and detect whether the end of the result set is reached.
To retrieve data from the result set as you traverse it, use appropriate getXXX methods of the ResultSet object, where XXX corresponds to a Java data type.
Example: Traverse the ResultSet object rs, retrieve the name of each customer, and print it.
while (rs.next()) {
System.out.println(rs.getString(1));
}
When the end of the result set is reached, the next() method returns false. Customer names are converted to Java string values.