This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
How do you know number of rows fetched by ResultSet?.
Size of ResultSet
Resultset
Resultset row count
how to get a number of record from the Resultset