This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Cloud Application Architecture Patterns: Designing, Building, and Modernizing for the Cloud and have Kyle Brown, Bobby Woolf and Joseph Yodor on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

ResultSet issues

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am writing a program which will query a database and return the results to a resultset. I am using a PreparedStatement object which runs the query and populates the resultset.
Then I loop through the resultset and store values returned for each row.
The code I use:-
rs = stmt.executeQuery();
while(rs.next)
{
aVariable = rs.getString(1);
}
The problem is that the while loop is extremely slow.
(the # of records is 20,000 in the database).
Is there a better way to loop through the recordset ?
Also, the executeQuery always returns a forward only recordset. How can one get a recordset with which one can use rs.last(),rs.first() or rs.movetoCurrentRow() etc.
Thanks in advance.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic