How PreparedStatement.executeQuery
works? Does it fetch results from database and I loop through them? Or it fetches the first result, and on record.next contin
You are doing it correctly. It fetches the entire results from your query, and you loop through them.
The internal pointer, or cursor, initially starts before the first row, so calling record.next()
will move it to the first row.
http://docs.oracle.com/javase/1.4.2/docs/api/java/sql/ResultSet.html#next%28%29