wood burning stoves 2.0*
The moose likes JDBC and the fly likes Number of rows returned? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Number of rows returned?" Watch "Number of rows returned?" New topic
Author

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
Marshal

Joined: Mar 22, 2005
Posts: 41597
    
  55
Calling rs.next() would return false right away if there were no rows returned.


Ping & DNS - my free Android networking tools app
Andy Grove
Greenhorn

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
Greenhorn

Joined: Jul 28, 2005
Posts: 3
Hi,
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.

sunny
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Number of rows returned?