Scott
We create a POOL in the a Servlets INIT() method (this is the OnLoad you refer
to). Its Object reference is stored a Servlets Instance Variable (1 Pool shared across
many Threads of
execution). (Unless the Servlet implements SingleThreadModel). The Constructor of the
POOL would define how many connections (min and Max) and UID/PWD/SID values etc....
At this point the Pool is available only that Servlet. If you want to share
the Instance of the Pool with other servlets, you could store the Object Reference in
the ServletContext (Which is
shared by Servlets running in the Same Context).
Running a refresh on a Code Table could involve using a Timer Thread (One
which calls back the Loaded Servlet @ intervals) the callback might then trigger the
SQL against the CODE TABLE to
refresh a local collection or Array.
The Pooled connections are shared across threads through Synchronized
methods(In the POOL), ensuring that 1 thread at a time gains access.
Some containers manage POOLS themselves (Like Websphere), and some Databases
(Like Oracle) can mask connections with Pooled Connections.
HTH
Bill
-----Original Message-----
From: Scott Watson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 21, 2001 1:47 PM
To: [EMAIL PROTECTED]
Subject: Server question (where is a connection pool kept and how does
it get there)
I have been reading this list for a couple of weeks now and have been scanning the
archives but I cannot find the answer to the
question I am currently stuck on.
I would like to know how the creation of a connection pool works. I understand how
the Pooling mechanism works and why it should be
used (I am an Oracle DBA) but what I don't understand is how it is instantiated in the
servlet container and remains in the
container available for all servlets in the application.
Where does the connection manger get started and how do you ensure that it is
available for all servlets to use within the context
of an application. When I was playing around with Tomcat and a simple servlet that
created its own connection I noticed the destroy
method was called not too long after there had been no activity. Therefore how does
the connection pool get created? I.e. each
servlet asks for a connection from the pool if it exits otherwise creates the pool and
the connection is returned?
Is there some "on load/on startup" servlet that can possibly create the connection
pool before any other servlet loads. For example
say I had a code table in a database that I would like to keep in a servlet context
and refresh every 15 minutes (can this sort of
operation be done).
Thanks for your help in advance,
Scott.
___________________________________________________________________________
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
___________________________________________________________________________
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
Re: Server question (where is a connection pool kept and how does it get there)
Lindsay, William (USPC.PCT.Hopewell) Tue, 21 Aug 2001 11:08:25 -0700
