> > Using a WeakHashMap might be a good solution. Connections are > guaranteed > > to be closed when they are garbage collected so if a client doesn't > return > > a connection and loses all pointers to it, the pool would lose its > > reference to it and the Connection would get gc'd. This is *much* > better > > than grabbing a connection away from the client application that may > still > > be using it. > > > > Using a weak reference for pooled connections which are in use is a good > idea > and I am all for it. > > The only problem is that there is no guarantee when the weak referenced > db connection pool object will be GC'd. That is highly dependent upon > how the JVM implements GC. There is no guarantee that this would > prevent > abandoned connections from causing the pool to be exhausted. >
That's a valid point but unlikely to happen in a highly loaded server JVM that's creating and destroying many objects. I think it's sufficient to say that the pool won't hold onto connections that apps have lost but it's up to the apps not to lose them in the first place. David > > > What would happen to the connection when it gets closed by garbage > > collection though? Since it's a pooled connection, calling close() > tries > > to return it to the pool but the pool lost its reference to the > connection > > when the client didn't return it. How would the pool ensure the > > connection originated from the pool? > > > > I'm sure that can be worked through. > > > David > > > > > > > >>In those circumstances garbage collection would free resources. I > would > >>think that their use is sensible so long as the pool can handle their > >>garbage collection and get another one (though that may have the knock > >>on > >>effect of causing the getting of the connection to be synchronized to > >>the > >>client request - not a huge big deal in most cases but in a well > managed > >>resource environment such weak references would be unnecessary. > >> > >>for an explanation see: > >>http://java.sun.com/j2se/1.4.1/docs/api/java/lang/ref/WeakReference.html > >> > >>Matt > >> > >> > > > > > ************************************************************************** > > > >>The information transmitted herewith is sensitive information intended > >>only > >>for use by the individual or entity to which it is addressed. If the > >>reader > >>of this message is not the intended recipient, you are hereby notified > >>that > >>any review, retransmission, dissemination, distribution, copying or > >>other > >>use of, or taking of any action in reliance upon this information is > >>strictly prohibited. If you have received this communication in error, > >>please contact the sender and delete the material from your computer. > >> > >>--------------------------------------------------------------------- > >>To unsubscribe, e-mail: [EMAIL PROTECTED] > >>For additional commands, e-mail: [EMAIL PROTECTED] > >> > > > > > > > > __________________________________ > > Do you Yahoo!? > > Yahoo! SiteBuilder - Free, easy-to-use web site design software > > http://sitebuilder.yahoo.com > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > -- > ---------------------------------------------------------------------- > Glenn Nielsen [EMAIL PROTECTED] | /* Spelin donut madder | > MOREnet System Programming | * if iz ina coment. | > Missouri Research and Education Network | */ | > ---------------------------------------------------------------------- > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
