• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP & JDBC

 
Harry Singh
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • 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
 
Preeti Rande
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u can cache the result.
 
Harry Singh
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • 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
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is a "disconnected ResultSet" ?
 
Harry Singh
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic