I think JDBC deliberately did not give us an API for that because it would force the resultset to retrieve all the rows for counting. The number could be high enough to be a serious performance drag. Under normal use the resulset retrieves some number of rows at a time as you move the cursor into them, but not all of at once.
A common suggestion is to run one query to select count and another to select the rows.
What do you want to do with the total number? Maybe we can figure out a way to live without it.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Apr 06, 2005
Thanks for your reply. But do you have any other method like scrollable result set..?
Joined: Jan 29, 2003
There are probably some SQL tricks ... select an extra computed column that is row number and sort descending so the first row has the row count. I'd still be more interested in making the requirement for row count go away.