next() method moves the cursor to the next row. So if you have no rows returned by your query, it will not enter the loop at all. From the API for next() of ResultSet
Moves the cursor froward 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.
Edit: As Steve already answered your query. The qoute above would add more context to it.