• 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

Maintaining scalability in servlets programming

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What should be done to maintain same database connection in all servlets & improve on scalability issue.
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to have the costly database connectins to be created alreday and ready for all servlets within an web application, you can create a COMMON Connection Pool of Database connections and put it in ServletContext. Each Servlet when first loaded checks for the connection-pool attribute in ServletContext, if not found then creates one and it volunteers to put it in servletCOntext. Essentially if there are 10 servlets in the whole web application ONLY one of the 10 will CREATE the connection pool and others just USE the already exisiting Connection pool in Servlet Context. I use this tech, and I add this code in init() of each servlet.
 
reply
    Bookmark Topic Watch Topic
  • New Topic