Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to find the number of rows in a Resultset object

 
ramchander yshetti
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
last() : Moves the cursor to the last row in this ResultSet object.
getRow() : Retrieves the current row number.

regards
 
Naseem Khan
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


regards


Naseem Khan
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34839
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramchander,
For a more detailed explanation, take a look at the first FAQ.
 
Scott Selikoff
author
Saloon Keeper
Posts: 4020
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In general you can't. Sometimes the driver and dbms support it but even it were to, you might be sacraficing portability.
 
Naseem Khan
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic