>>> Dave Ford <[EMAIL PROTECTED]> 25-Jun-00 5:16:03 PM >>>

>I have just spent the last day researching the topic of
>Database Connection Management and connection pooling,
>and now realize, that there are too many choices. I would
>like to summarize what I have learned and perhaps someone
>can correct me where I'm wrong or add a comment.

Great summary. May I add a few things?


>2. Pooled JDBC Connections:
>a. One pool per servlet (Pool as static variable of servlet)
>b. One pool per application (Store pool in ServletContext)
>c. One pool per application (Store pool as singleton)
>d. One pool per application (Store pool in jndi server)
>It seems to me that 2d, is what Sun is recommending.

For MOST applications 2d is good (though I personally prefer 2b).

But another excellent way of doing it is to have a Connection per
session. You would use that in an application that required
authenticated connections or some low-level (eg: table level)
security.

It's best suited to apps where the user is going to be doing querying
over a long period of time and the querying is specific to the user
(perhaps an accounting tool where each user has different rights).



There are some things that you've missed.


- Pooling other SQL objects
There are general pooling classes available to allow you to pool any
object. You could, for example, pool PreparedStatements with such a
pool - you setup the PS in the init() method - add it to the
generalized pool and checkout/in as needed in the service method.

This works well when you have one, or a few, queries that each user
of the system will repeatedly execute and when those queries are
generalized across all users.


- deliver a pool with your application
Portability is not so much of a concern with a simple pooling system.
It would be nice if all JDBC drivers offered pooling but until they do
it's safer to just deliver a pooling class with your application.



Nic Ferrier

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to