aspose file tools
The moose likes JDBC and the fly likes how to find out how many records returned in recordSet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "how to find out how many records returned in recordSet" Watch "how to find out how many records returned in recordSet" New topic
Author

how to find out how many records returned in recordSet

k Oyedeji
Ranch Hand

Joined: Jul 07, 2002
Posts: 96
Hi
I have had a look at the documentation for RecordSet but cannot find a field or a method
which returns a count of the amount of records
returned from a query. Do i have to loop through the recordset to find out how many results were
returned?
Thanks
Kola
Claudio Gualberto
Ranch Hand

Joined: Oct 13, 2002
Posts: 47
Kola wrote :
"Do i have to loop through the recordset to find out how many results were returned?"
yes, this is the only way i know to get this information. I'm not a SQL expert and dont know if
there's a SQL statement to bring this kind of information into the resultset, but it's a interesting subject of study.
Philip Shanks
Ranch Hand

Joined: Oct 15, 2002
Posts: 189
For a scrollable RecordSet object, I resorted to:

Then you can do rs.first(); to "rewind" to the beginning.
You just have to keep in mind the offset: row numbering is "1" based, while array indices are zero based.
[ October 15, 2002: Message edited by: Philip Shanks ]

Philip Shanks, SCJP - Castro Valley, CA
My boss never outsources or has lay-offs, and He's always hiring. I work for Jesus! Prepare your resume!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: how to find out how many records returned in recordSet
 
Similar Threads
How to handle deleted records after find
ResultSet issues
Using a MIDlet to navigate a database recordset
Stored Procedure Problem
Problem withUpdatable Resultset