Looping through the ResultSet efficiently and the add the values for columns in List
I am not that familiar with JDBC, but I think the method you search for is: isBeforeFirst: "true if the cursor is before the first row; false if the cursor is at any other position or the result set contains no rows"

This does not modify the results cursor then.



if (id &gt;= startValidRange &amp;&amp; id &lt;= endValidRange)


I would change it to:

if (startValidRange &lt;= id &amp;&amp; id &lt;= endValidRange)


Only a small change, but increase readability a lot (at least for me)