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
posted
0
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
posted
0
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>