If you are using a
JDBC 2.0 compliant driver, there is one other way to get the row count:
resultSet.last();
int numRows = resultSet.getRow();
Note that depending on your database and driver, that the above may not be a good solution. For instance, the Oracle driver caches the rows in memory as you traverse the result set. If your result set is very large, then this could exhaust memory. If you don't care about making two accesses to the db, then the 'select count(*)...' technique is safer; but if you know your result set will be relatively small, and you only want to make on db access, then use getRow().