Hello all

I have a question about defining data-sources in tomcat. I have a webapp in
which my servlets need to talk to a DB. This is my current setup:

1) I define data-sources (c3p0 connection pools) using the Resource tag in
my META-INF/context.xml.
2) The web.xml has references these data-sources via resource-env-ref tags
3) In my servlet init(), I lookup the data-source. Each lookup essentially
instantiates an instance of the data-source. So a connection pool gets
instantiated in each servlet's init.

Now it doesn't make sense to create a new connection pool in each servlet.
So I'd like to create a single connection pool that will be used by all
servlets. I've been looking thru the tomcat docs, to see where I could
create this central resource for my webapp. The only option I've seen so far
is to create my own life-cycle listener for my webapp. That way I can create
a connection pool on start-up. I was wondering if there was a better way to
do this ?

       Thanks

      Srinivas

Reply via email to