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

Reply via email to