In many servlet engines, a custom class loader is used to load servlets, so
that automatic reloading can be performed when you modify it.  If your
connection pool code is loaded by one of these class loaders, then it is
really *not* shared across the entire virtual machine.  It is only shared with
other classes loaded by that same class loader -- I understand, for example,
that JWS uses a class loader instance per servlet, which could cause the
effects you describe below.

Try making sure that the connection pool class (and the JDBC driver it uses)
is on the system class path used to load your servlet engine, and *not* on the
path used to load your servlets.

Craig McClanahan


SAN wrote:

> When I thougth my problems with connection pools had finished, I realise
> that it doesn't do what it's supposed to do. (Probably because my code
> isn't very good) OK, here goes the pseudo-code:
>
> In each servlet:
>
> Connection con =null;
> Pool pool = null;
> init()
> {
>     pool = Pool.getPool();
> }
> service(){
> con = pool.getConnection();
>
> // use con
>
> pool.returnCon(con);
> }
>
> And the pool:
>
> class Pool() {
>    static private Pool instance = null;
> static synchronized public Pool getPool() {
>
>         if(instance==null) {
>            instance = new Pool();
>         }
>         return instance;
>   }
>
> private Pool() {
>     ...
> }
>
> The problem is that a pool is created for each servlet. As you can see,
> if the instance is not null, getPool() returns a created one. But the
> constructor is ALWAYS executed when I call a new getPool(). Once the
> pool is created, it serves connections to ITS own servlet (which is not
> too useful). What happen? The instance variable is static, so should be
> shared within the virtual machine.
>
> Any idea, corrections, whatever ?
> Thanks.
>
> ___________________________________________________________________________
> 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

Reply via email to