there are several ways ,
one is to use setFetchsize(), by this way you set the fetch size explicity
The other one is to execute a select count(...) statement after or before your orijinal statement execution .
another way is to count the rows one by one
and the last way that i know is