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 what is fastest way to retrive rows from a resultSet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "what is fastest way to retrive rows from a resultSet?" Watch "what is fastest way to retrive rows from a resultSet?" New topic
Author

what is fastest way to retrive rows from a resultSet?

raminaa niilian
Ranch Hand

Joined: Jul 14, 2005
Posts: 551
Hi
Thank you for reading my post.
What is fastest way to retrieve the records from ResultSet?
should i create a while loop and use rs.next to find all rows
or there is some other way , for example to convert the result set to a colletion / iterator? of its rows.

i do not need any metadata or other stuff that a ResultSet provide , i just need data rows.
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
Thank you for reading my post.

Okay.
What is fastest way to retrieve the records from ResultSet
should i create a while loop and use rs.next to find all rows

Yes.
or there is some other way

No.
for example to convert the result set to a colletion / iterator? of its rows.

Filling a collection with your rows is often a good idea for other reasons but you are still using rs.next or whatever to get each row. And by whatever I mean you could use absolute or something as well or go to the end of a scrollable result set and move backwards but at the end of the day you still have to fetch all the rows using the ResultSet.

Also please don't be confused the best way by far will be next. Anything else will be slower. If performance is an issue look into manipulating the fetch size of your cursor. using a forward only read only cursor may also help and as always write good SQL... only SELECT the rows you actually need.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is fastest way to retrive rows from a resultSet?