• 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

Dynamic Connection Pool

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I created a ConnectionPool for a Tomcat web application and it works great. I used the Singleton pattern. It measurably improved the performance of the application. But in our enterprise, we have several environments (test-dev-production) where we connect to different databases. Is there a way of making one ConnectionPool class that could serve different databases or named connection pools? It seems with the Singleton pattern, you'd have to create a separate connection pool class for each connection pool you have configured. I hope this makes sense.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Charles,
Did you write your own class? Using a library like dbcp means you don't have to write any classes; just ocnfigure as many connection pools as you want.
 
Charles Owen
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I created a custom ConnectionPool class.

 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you write your own, then yes - you would need multiple logical classes. Which could be one class with configurable parameters. For example if you call MyConnectionPool.getInstance("test") or MyConnectionPool.getInstance("prod"), it would return a singleton for that parameter. MyConnectionPool would store a map of keys to logical singletons.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic