File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Number of rows returned? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Number of rows returned?" Watch "Number of rows returned?" New topic

Number of rows returned?

Bloo Barton
Ranch Hand

Joined: May 09, 2005
Posts: 63
When I get my ResultSet how can I quickly check that rows have been returned so I am not trying to access data that is possibly not there?
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
Calling would return false right away if there were no rows returned.
Andy Grove

Joined: Nov 11, 2003
Posts: 18
If you want to know the number of rows before processing them, you could always issue a "SELECT COUNT(*) FROM TABLE WHERE ...." SQL statement first.
sunny sri

Joined: Jul 28, 2005
Posts: 3
if you want to know the no of rows in resultset without doing any work on that,then you just give the method last() on the resultset then it goes to last row of resultset.After that you can call the method getrows() it will give the return type int (row no)then you can easily find out the no rows.
see the method currectly(getrows())in API.

I agree. Here's the link:
subject: Number of rows returned?
It's not a secret anymore!