aspose file tools*
The moose likes JDBC and the fly likes Number of rows in a ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Number of rows in a ResultSet" Watch "Number of rows in a ResultSet" New topic
Author

Number of rows in a ResultSet

Warren Bell
Ranch Hand

Joined: Dec 20, 2000
Posts: 56
How do you find out how many rows there are in a ResultSet without running through every row and counting them?


Warren Bell
SJ Adnams
Ranch Hand

Joined: Sep 28, 2001
Posts: 925
what I've done in the past is to alias the rownum & order it desc in a subquery. that way you get the total number of rows of the query in the very first row.
I'm sure there are better ways - I guess it depends if you prefer to load the rdbms or the application.
Simon
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Number of rows in a ResultSet
 
Similar Threads
Resultset
how to get a number of record from the Resultset
Size of ResultSet
How do you know number of rows fetched by ResultSet?.
Resultset row count