codice:
RecordSet rs = rs.executeQuery();
while(rs.next()){
}
rs.next() serve per spostarsi tra i record.

Dalla documentazione:

public boolean next()

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.
Quindi entra nel file se trova almeno un record e smette di iterare quanto non ci sono più record (dopo averli letti tutti).