That's right, initially, the ResultSet's cursor is pointing to before the first row if the initial call to next() returns invalid then there was no data in the ResultSet.
If you try this way, you may have to call beforeFirst()immediately after to reset it, since it has placed itself past the first row now.