This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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.
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.