Meaningless Drivel is fun!*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 39542
    
  27
Calling rs.next() would return false right away if there were no rows returned.


Ping & DNS - updated with new look and Ping home screen widget
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?
 
Similar Threads
efficient way to update data
counting rows after joins varies
How can i count the returned rows from a daabase ?
Adding the rows in a JSP
How to find the number of rows in the resultset