The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes a question about Singleton Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Architect Certification (SCEA/OCMJEA)
Reply Bookmark "a question about Singleton" Watch "a question about Singleton" New topic
Author

a question about Singleton

Timber Lee
Ranch Hand

Joined: Oct 14, 2002
Posts: 157
You are creating a web application for an online product ordering system. You will be using data from several different databases and to reduce the load on the databases you have decided to use connection pooling. You have a ConnectionPool class and you want one pool for each database. However, you will have to connect to a variable number of databases. What pattern should you use?
Singleton
Prototype
Builder
Factory Method


SCJP<br />SCWCD<br />SCEA
Rufus BugleWeed
Ranch Hand

Joined: Feb 22, 2002
Posts: 1551
You will get an instance of javax.sql.DataSource from JNDI for each database. DataSource knows how to pool. Since DataSource is an interface, and the DB vendor supplies classes that implement it, is it a Prototype?
Sanjay Raghavan
Ranch Hand

Joined: May 14, 2002
Posts: 148
In your example the answer would be a factory of singleton pools. Each pool can be represented by a singleton and a reference to the desired pool can be dynamically obtained via the ConnectionPoolFactory
HTH.


Sanjay Raghavan<br />SCJP2, SCEA-J2EE<br />Moderator - <a href="http://groups.yahoo.com/group/scea_prep" target="_blank" rel="nofollow">SCEA PREP</a><br />Co-Author - <a href="http://www.whizlabs.com/scea/scea.html" target="_blank" rel="nofollow">SCEA@Whiz</a><br /><i>Where did you sip your Java Today?</i>
 
 
subject: a question about Singleton
 
Threads others viewed
Weblogic cluster question
FBN - Design choices
Question about design pattern
a mock quiz about Design Pattern
Pattern used in the qn
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture