File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Count of Records Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JDBC
Reply Bookmark "Count of Records" Watch "Count of Records" New topic
Author

Count of Records

Sridhar M Swaminathan
Greenhorn

Joined: Apr 08, 2002
Posts: 7
Hi All..
Which is the best method to count the number of records retrieved by an SQL??
Is it to navigate through the RecordSet till the end? or is there a better method ?
Pls suggest
Thanks
Sridhar
Rajendar Goud
Ranch Hand

Joined: Mar 06, 2002
Posts: 220
Hi sridhar,
it depends on ur requirement.To keep a count of the number of records in the middle of the query,
then u can define a integer variable and keep incrementing it after each retreiving each record.
i already posted the code in this forum some time back..
cheers,
Raj
Mahesh Mamani
Ranch Hand

Joined: Jun 25, 2001
Posts: 110
Hi,
Instead of traversing the whole ResultSet and then getting the count, a simpler option is do get the count of the rows using the statement
select count(*) from <table-name>
Hope It Helps.

Mahesh
Sridhar M Swaminathan
Greenhorn

Joined: Apr 08, 2002
Posts: 7
Hi Raj & Mahesh..
Thanks
 
 
subject: Count of Records
 
Threads others viewed
getRecordCount()
Why getProperty values a different data records
records not showing in ResultSet
Calling methods in a loop
Record Count
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture