There is a way to find out though without iterating through the entire result set and incrementing a counter along the way.
Just issue another select beforehand of the form:select count(*) from ( YOUR SELECT STATEMENT HERE )
This will give you a result set with 1 row and 1 column containing a value representing the row-count of the select statement you want to execute.
True. But *why* do you want to know the rowcount before processing the result? In the data tier the results are generally mapped to a Collection of DTO's which can be used in the presentation tier. Then you can just use Collection#size() to get the rowcount. If you aren't about to do something with the result, then indeed rather gently use a COUNT(*) query and retrieve the rowcount by resultSet.getInt(1).