wood burning stoves*
The moose likes JDBC and the fly likes How to find the number of rows in a Resultset object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to find the number of rows in a Resultset object" Watch "How to find the number of rows in a Resultset object" New topic
Author

How to find the number of rows in a Resultset object

ramchander yshetti
Ranch Hand

Joined: Apr 22, 2006
Posts: 97
Hi All,

I am facing a problem in finding how to know the number of rows/records in a Resultset object.

Plz. give the possible ways other than using a counter variable and incrementing in while we traverse the resultset using a loop.

Bye
Ramchander
fred Joly
Ranch Hand

Joined: Jan 19, 2006
Posts: 55
last() : Moves the cursor to the last row in this ResultSet object.
getRow() : Retrieves the current row number.

regards
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809


regards


Naseem Khan


Asking Smart Questions FAQ - How To Put Your Code In Code Tags
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30776
    
157

Ramchander,
For a more detailed explanation, take a look at the first FAQ.


[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
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

In general you can't. Sometimes the driver and dbms support it but even it were to, you might be sacraficing portability.


My Blog: Down Home Country Coding with Scott Selikoff
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
Hi Scott,

Its not the question of dbms.

Once you get the result in a ResultSet, now the question is whether your JDBC driver support Scrollable ResultSet or not.

Regards

Naseem
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to find the number of rows in a Resultset object