----- Original Message ----- From: "sinoea kaabi" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Friday, September 19, 2008 9:18 AM
Subject: RE: Tomcat 5.5, JNDI Connection Pooling, Active connections keep increasing....



You aren't using any class-level
members in your static methods so you should be fine.

This means that I cannot declare a:

public class Data {

private static DataSource datasource = null;

public static DataSource getDataSource() {
     if (datasource == null) {
        // create a datasource
     }
     return datasource;
}

}

In the code above the class-level member is the datasource.

Do you mean I should do like this instead:

public class Data {


public static DataSource getDataSource() {

     // create a new datasource for each call to this method

     return datasource;

}



}

-----------------------

Hi sinoea....

If a datasource in DBCP represents the pool... you cant, you'd make a million data pools...

These are the innocent looking things that can give problems...

The new trick to isolate the class global vars wont help in this case
So in theory... all access to that datasource variable should be synch'd...

In the routine you showing and in all the others that use it...

You dont sync at method level
public static DataSource getDataSource()

you just sync access to that shared global....

The Java tut has examples of the various ways to sync method and code sections...

As soon as more than one thread is sharing something... you either try change the structure so that its not shared or you sync it... it is normally too difficult to imagine the possible race conditions...
The java tut has some example on just how tricky it can be as well...

---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to