This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ResultSet, Statement Caching In Tomcat, Servlets

 
Vikas Aggarwal
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Hitting the server and database for same kind of data involves the use of same Statements and use of same ResultSets over and over again.
I want to run the queries at the server start up and store tha data somewhere on application level so that it can be accessible to all of the servlets. Also this method should also avoid the concurrency issues.
Thanks for your help.
 
Ken Robinson
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you just want to get a Collection of rows at startup and never refresh them, that is quite easy.
Create a Bean to hold a row of data. During startup of the app (via a Startup Servlet or ContextListener -2.3), run the query, build the Collection of Beans and put the Collection in the Servlet Context. Now it is available to all Servlet/Filters/JSP in the app.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic