• 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

JSP & JDBC

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Java Gurus,
While reading JSP & JDBC, a doubt just came in my mind.Suppose my query fetches about ten lacks or may be more results from the DB.How will i handle it programatically. if there are so many results in ResultSet object, then will this object be in memory and this is also not a right approach to keep this object in memory.
If i try to get less results from DB, then i will have to do DB operations again and again, which is also not a desirable approach..
so what wil be the best approach in this context..
Thanks in advance..
Regards,
Harry
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
u can cache the result.
 
Harry Singh
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
How can i cache the result and even if i cache the result that will mean that the object will be in memory...
Out of these 10 lakhs record or may be more, i wanna display just 100 at a time on page. i can do this by pagenation, but do i need to make DB intensive operations everytime or i can get all the results from DB is one single object.
Thanks in advance
Regards,
Harry
 
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
There are a number of solutions and most have been covered in this forum, as weel as the Servlets and JDBC forums. I recommend searching these forums for "ResultSet paging" first.
The solution you choose will depend on the frequency of searches, the expected number of results, the size of each item, whether the query is cached or needs to be constantly updated from the DB, what load you are allowed to put on the database, how much network traffic you expect and other issues.
There is no single solution, it depends on how the factors above relate to your particular situation.
You could cache the results on the session, you could cache the results on the application if you expected others to execute the same query, you could store just the IDs on the session and load the data as required, you could execute the entire query every time and pull off the entries you wanted, you could use a disconnected ResultSet, you could use a paged ResultSet (ie only return results 101 to 200) or one of many other solutions.
Have a look at previous discussions we've had.
Dave
 
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is a "disconnected ResultSet" ?
 
Harry Singh
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,
Can we know about the disconnected resultSet, never heard of it.
how do we usually cache a ResultSet object. Does that means stroing object in session.
Thanks in advance,
Regards,
Harry
 
reply
    Bookmark Topic Watch Topic
  • New Topic