• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Retrieving big list from that database and memory

 
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi:
How can I retrieve a big list from the database without consuming so much memory?
In my model, I use transfer objets to bring the data from the database to my application. Basically, I read every row from the ResultSet, then I encapsulate it into a corespondent object. But, what will happen if I have too many rows in the ResultSet? I will have to create too many objects, which will take too much memory.
Not: Also, I want to mentain a relationship to the acual record, for example: I want to retrieve all the the internet providers from the database, and display the name to the user, when the user click on the name, my DAO should retrieve the provider data and display it to the user. But if I have 1000 providers, I will have to create 1000 objects.
how can I solve this problem?
I am new to the database stuff, and any help is appreciated.
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm afraid there's no easy answer to this. You can try to tailor your SQL statement to return a smaller ResultSet. Barring this though, I'm afraid you're stuck. You could of course just read in primary key values and then read in the actual ones you need when you need them. That would incur more network traffic though. However, your memory footprint would be smaller.
I suppose you'll just have to weigh the options and your performance/memory needs.
 
reply
    Bookmark Topic Watch Topic
  • New Topic