commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anton Tagunov <atagu...@mail.cnt.ru>
Subject Re[2]: [DBCP] connection pool shutdown
Date Fri, 04 Jul 2003 19:03:31 GMT
Hello, Srinath!

sn> But I don't want the context to be reloaded as well.
sn> I just want to terminate all the connections to the database.
sn> I am using sql server, if I want to rebuild user security or restore
sn> database,
sn> there should not be any connection to the database. So I just need to close
sn> all the connections.

well, I doubt it can be done with fetching the datasource
via JNDI, but you could

a) make all the access to the pool via the ServletContext
b) implement a specialized managing servlet
   that would act on two uri-s: /down and /up

   on /up it would
   1. fetch the DataSourcePreviously bound into ServletContext
   2. call .close() on it
   3. create a new BasicDataSource
   4. bind it into the ServletContext

   on /down it would
   1. unbind the datasource from ServletContext, call
   2. call .close() on it

c) implement a ServletContextListener that would
   on servlet application startup create a new DataSource
   and bind it into the ServletContext

d) all the components using the DataSource should be
   prepared to handle the situation when they find
   no BasicDataSource in the ServletContext
   (since it may have been /down-ed)

   alternatively (if your servlet api < 2.3)
   you may use not a ContextListener, but
   the same servlet that handles /up and /down
   could on its startup do it

e) you should properly safeguard access to these
   /up and /down url-s to prevent malicious user
   from bringing your database access down.

   at the very minimum you would probably want
   to shield them with username/password in
   the normal way it is done with Tomcat
   (or Apache httpd if you're running via it)

Please consider sending your control servlet back
to the list after you have this up and running.
   
-Anton


Mime
View raw message