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

Needs ur help - - Urgent !

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear friends,
i am developing a website.
i have one jsp page called display.jsp which is displaying records for multiple pages.

every page i set the number of record display is 20.
i am retriving data from java bean calling from display.jsp .
i have done in java bean as retriving data from database and have kept in one jave collection object Vector.
database can have million records.is it efficient to move all data to Vector?
if not so, how to retrive data from database first time 20 records starts from 0 to 20, next 20 records starts from 21 to 40 like that?
please any one give solution for this?
regards
saran
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paging ResultSets has been covered multiple times and I recommend a search of this forum as well as the JSP and JDBC forums.
If you have the possibility of returning so many rows, it probably isn't a good idea to return them all and store them in a Vector. It won't take long to run out of memory and is even worst if the bulk of the data is never used (ie if 90% of the people only look at the first 2 pages anyway)
Firstly you should look at setting an upper limit on the rows returned, like 100 or 200, maybe even 500. You may find that in your case it is better to include the paging functionality in the SQL so that the DB only returns the exact data you are currently interested. Code ion doing this can be found here
Another possibility is to do a 'light search' first. Do a search that returns all of the rows, but only includes the primary key. This will be much lighter and then you can pull the IDs from this list to load only the specific data you need.
Regardless of what some may say, there is no single silver bullet for ResultSet paging. Have a look at the options available and use the one that fits your problem.
Hope this helps.
Dave
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also take a look at the Value List Handler pattern from Sun's J2EE Core Design Patterns. This can be used together with the Primary Key query approach to enable lazy loading of pages of data, with forward, back buttons, etc.. I would minimise the usage of a ResultSet and never hold onto it longer that the initial JDBC queries.
Paul
[ January 09, 2003: Message edited by: Paul Done ]
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic