File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is fastest way to retrive rows from a resultSet?

 
raminaa niilian
Ranch Hand
Posts: 551
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 381
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic