aspose file tools*
The moose likes JDBC and the fly likes Is it possible to get rowCount from ResultSet Object? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Is it possible to get rowCount from ResultSet Object?" Watch "Is it possible to get rowCount from ResultSet Object?" New topic
Author

Is it possible to get rowCount from ResultSet Object?

Thennam Pandian
Ranch Hand

Joined: Oct 11, 2005
Posts: 163
Consider I am executing the following query.



and i want to get the total number of records from resultSet Object.

Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31062
    
232

You have two options. One is to run select count(*) from table. The other is to loop through the result set and count as you go.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3097
    
  33

I think even getFetchSize returns the number of rows fetched by the ResultSet.


Mohamed Sanaulla | My Blog
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31062
    
232

mohamed sanaullah wrote:I think even getFetchSize returns the number of rows fetched by the ResultSet.

No. It returns the number of rows fetched at a time. It does not return the total number of records.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is it possible to get rowCount from ResultSet Object?