Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Needs ur help - - Urgent !

Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • 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 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?
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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.
Posts: 22
  • Mark post as helpful
  • send pies
  • 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.
[ January 09, 2003: Message edited by: Paul Done ]
Your buns are mine! But you can have this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic