You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Martin Dyulgerov <ne...@gmail.com> on 2008/12/01 18:17:42 UTC

DBCP problem with idle object

Hello group!

This is the first time i actuali write something in here. First of all - 
please excuse my bad english, it is not my native language. Now to get 
to the point... I have problems implementing DBCP on my Tomcat 6.0.18 in 
my web applications. I don't want to use JNDI, that is why i have 
ServletContextListener, in witch i do as follows in order:

1.Define GenericObject Pool
2. Define ConnectionFactory as implementation of 
DriverManagerConnectionFactory
3.Define PoolableConnectionFactory with the previously created 
GenericObjectPool and ConnectionFactory
4.Define PoolingDataSource with the GenericObjectPool object from step 1

Then i "stick" my PoolingDataSource to the servlet context, retreive it 
in my JSPs and servlets and aquire a connection via "getConnection()" 
(which returns Connection object). I make sure to close() all my 
connections at the edn of the pages...I am sure that the connections 
that are opened dont exceed the number 100 (which is the maximum number 
of connections on my database - a MySQL database system), so i think 
there must be something wrong with my pooling code. The exact error i 
get is:

"Exception: Cannot get a connection, pool error Timeout waiting for idle 
object SQL Exception Connection is closed. SQLException Connection is 
closed." At some point i began to ask myself if it the problem is caused 
by the restarts(reloads) i do for that exact application, because the 
other work fine (byt i dont play with them that much)... My 
configurations for the GenericObjectPool and 
DriverManagerConnectionFactory are as follows:

GenericObjectPool.Config config=new GenericObjectPool.Config();
            config.maxActive=15;
            config.maxIdle=10;
            config.minIdle=5;
            config.maxWait=3000;
            config.testOnBorrow=true;
            config.testOnReturn=true;
            config.testWhileIdle=true;
            config.timeBetweenEvictionRunsMillis=1000;
            config.minEvictableIdleTimeMillis=1000;

Properties p=new Properties();
            p.setProperty("user", user);
            p.setProperty("password", password);
            p.setProperty("useUnicode", "true");
            p.setProperty("characterEncoding", "CP1251");
            p.setProperty("autoReconnect", "true");

Can You help me please? Any help will be appriciated. Thanks in advance, 
and accept my apologies if i have breaked some rules of the group or 
something like that.

All best,

Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: DBCP problem with idle object

Posted by Martin Dyulgerov <ne...@gmail.com>.
Thank you Phil! I see the logic in your reply. I'll try those 
suggestions, first thing today. I'll remove the following setting from 
my file:

config.minIdle=5;
config.timeBetweenEvictionRunsMillis=1000;
config.minEvictableIdleTimeMillis=1000;

Hope it works!

Best regards,

Martin

Phil Steitz wrote:
> Martin Dyulgerov wrote:
>> Hello group!
>>
>> This is the first time i actuali write something in here. First of 
>> all - please excuse my bad english, it is not my native language. Now 
>> to get to the point... I have problems implementing DBCP on my Tomcat 
>> 6.0.18 in my web applications. I don't want to use JNDI, that is why 
>> i have ServletContextListener, in witch i do as follows in order:
>>
>> 1.Define GenericObject Pool
>> 2. Define ConnectionFactory as implementation of 
>> DriverManagerConnectionFactory
>> 3.Define PoolableConnectionFactory with the previously created 
>> GenericObjectPool and ConnectionFactory
>> 4.Define PoolingDataSource with the GenericObjectPool object from step 1
>>
>> Then i "stick" my PoolingDataSource to the servlet context, retreive 
>> it in my JSPs and servlets and aquire a connection via 
>> "getConnection()" (which returns Connection object). I make sure to 
>> close() all my connections at the edn of the pages...I am sure that 
>> the connections that are opened dont exceed the number 100 (which is 
>> the maximum number of connections on my database - a MySQL database 
>> system), so i think there must be something wrong with my pooling 
>> code. The exact error i get is:
>>
>> "Exception: Cannot get a connection, pool error Timeout waiting for 
>> idle object SQL Exception Connection is closed. SQLException 
>> Connection is closed." At some point i began to ask myself if it the 
>> problem is caused by the restarts(reloads) i do for that exact 
>> application, because the other work fine (byt i dont play with them 
>> that much)... My configurations for the GenericObjectPool and 
>> DriverManagerConnectionFactory are as follows:
>>
>> GenericObjectPool.Config config=new GenericObjectPool.Config();
>>            config.maxActive=15;
>>            config.maxIdle=10;
>>            config.minIdle=5;
>>            config.maxWait=3000;
>>            config.testOnBorrow=true;
>>            config.testOnReturn=true;
>>            config.testWhileIdle=true;
>>            config.timeBetweenEvictionRunsMillis=1000;
>>            config.minEvictableIdleTimeMillis=1000;
>>
>> Properties p=new Properties();
>>            p.setProperty("user", user);
>>            p.setProperty("password", password);
>>            p.setProperty("useUnicode", "true");
>>            p.setProperty("characterEncoding", "CP1251");
>>            p.setProperty("autoReconnect", "true");
>>
>> Can You help me please? Any help will be appriciated. Thanks in 
>> advance, and accept my apologies if i have breaked some rules of the 
>> group or something like that.
> These settings make it hard for the pool to manage connections:
>           config.maxIdle=10;
>           config.minIdle=5;
>           config.timeBetweenEvictionRunsMillis=1000;
>           config.minEvictableIdleTimeMillis=1000;
>
> The first two force the pool to try to keep the number of idle 
> connections between 5 and 10, which is going to force it to close / 
> open frequently to stay within that relatively narrow range.   Unless 
> you really need both of these, I would recommend eliminating one or 
> both of them.
>
> The second two are probably the source of your problem.  These 
> parameters are specified in milliseconds (thousandths of a second).  
> The first one tells the pool to kick off an evictor run every second 
> and the second tells it to destroy any connections that sit idle for 
> more than a second.  This will create lots of connection churn and 
> also pool access contention as the idle object evictor runs every 
> second and closes connections that have been idle and then tries to 
> create new ones to reach minIdle.  You should either increase both of 
> these by at least an order of magnitude or drop  them.   Unless you 
> really want to close connections that have been idle in the pool for 
> longer than a specified idle timeout, I would drop these.
>
> Phil
>
>
>
>
>>
>> All best,
>>
>> Martin
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>



Re: DBCP problem with idle object

Posted by Martin Dyulgerov <ne...@gmail.com>.
Phil Steitz wrote:
> Looks like you may not be closing your connections on all control 
> paths.  Are you sure there are not exception conditions that could 
> cause your close() activations to be missed?
Hello again. I am sure that in every JSP or servlet I am closing thje 
connections with the following piece of code:

            try
            {
                pConn.close(); // my connections, gained from the 
PoolingDataSource, they are of type Connection
            }
            catch(Exception exc)
            {
                System.out.println("Exception: "+exc.getMessage());
                out.println("Exception: "+exc.getMessage());
            }
MySQL shows opened only one connection when the pool seems to be 
working. I dont know what is causing the pool to stop working and giving 
the exception. As a result of my further research on the problem on the 
Internet yesterday, I am now using the following settings for the pool:

GenericObjectPool.Config config=new GenericObjectPool.Config();
config.maxActive=50;
config.maxWait=-1;
config.testOnBorrow=true;
config.defaultAutoCommit=true;
config.minIdle=0;
config.testWhileIdle=false;

I am going to continue my work on the project, so if the exception shows 
again I'll know in a matter of hours. Thanks for your replies.

Martin


Re: DBCP problem with idle object

Posted by Phil Steitz <ph...@gmail.com>.
Martin Dyulgerov wrote:
> Hello again group!
>
> Phil: I followed your advice and remove some of the configuration 
> lines for my pool, here is the configuration i use at the moment:
>
> GenericObjectPool.Config config=new GenericObjectPool.Config();
> config.maxActive=15;
> config.maxWait=1000;
> config.testOnBorrow=true;
>
> and still i get the following error:
>
> "Exception: Cannot get a connection, pool error Timeout waiting for 
> idle object SQL Exception Connection is closed. SQLException 
> Connection is closed."
>
> MySQL shows that there are active 19 connections (19 rows in set (0.00 
> sec)) as a result of "mysql> SHOW FULL PROCESSLIST\G; "... When i 
> begin to work on my application (about 3 hours earlier today), there 
> were only 6 connections, and then, at some point they increment to 
> that number (i am more than sure that no one is using the application 
> besides me, and all the connections use the same database as my 
> application - so they have to belong to it, to the pool) My 
> application is running for about 7 hours to this moment after i made 
> the changes and restarted it. Can you please help me with some 
> suggestions onconfiguring the pool wright... I am getting pretty 
> desperate by now :( Thanks in advance!
Looks like you may not be closing your connections on all control 
paths.  Are you sure there are not exception conditions that could cause 
your close() activations to be missed? 
>
> Martin
>
> Phil Steitz wrote:
>> Martin Dyulgerov wrote:
>>> Hello group!
>>>
>>> This is the first time i actuali write something in here. First of 
>>> all - please excuse my bad english, it is not my native language. 
>>> Now to get to the point... I have problems implementing DBCP on my 
>>> Tomcat 6.0.18 in my web applications. I don't want to use JNDI, that 
>>> is why i have ServletContextListener, in witch i do as follows in 
>>> order:
>>>
>>> 1.Define GenericObject Pool
>>> 2. Define ConnectionFactory as implementation of 
>>> DriverManagerConnectionFactory
>>> 3.Define PoolableConnectionFactory with the previously created 
>>> GenericObjectPool and ConnectionFactory
>>> 4.Define PoolingDataSource with the GenericObjectPool object from 
>>> step 1
>>>
>>> Then i "stick" my PoolingDataSource to the servlet context, retreive 
>>> it in my JSPs and servlets and aquire a connection via 
>>> "getConnection()" (which returns Connection object). I make sure to 
>>> close() all my connections at the edn of the pages...I am sure that 
>>> the connections that are opened dont exceed the number 100 (which is 
>>> the maximum number of connections on my database - a MySQL database 
>>> system), so i think there must be something wrong with my pooling 
>>> code. The exact error i get is:
>>>
>>> "Exception: Cannot get a connection, pool error Timeout waiting for 
>>> idle object SQL Exception Connection is closed. SQLException 
>>> Connection is closed." At some point i began to ask myself if it the 
>>> problem is caused by the restarts(reloads) i do for that exact 
>>> application, because the other work fine (byt i dont play with them 
>>> that much)... My configurations for the GenericObjectPool and 
>>> DriverManagerConnectionFactory are as follows:
>>>
>>> GenericObjectPool.Config config=new GenericObjectPool.Config();
>>>            config.maxActive=15;
>>>            config.maxIdle=10;
>>>            config.minIdle=5;
>>>            config.maxWait=3000;
>>>            config.testOnBorrow=true;
>>>            config.testOnReturn=true;
>>>            config.testWhileIdle=true;
>>>            config.timeBetweenEvictionRunsMillis=1000;
>>>            config.minEvictableIdleTimeMillis=1000;
>>>
>>> Properties p=new Properties();
>>>            p.setProperty("user", user);
>>>            p.setProperty("password", password);
>>>            p.setProperty("useUnicode", "true");
>>>            p.setProperty("characterEncoding", "CP1251");
>>>            p.setProperty("autoReconnect", "true");
>>>
>>> Can You help me please? Any help will be appriciated. Thanks in 
>>> advance, and accept my apologies if i have breaked some rules of the 
>>> group or something like that.
>> These settings make it hard for the pool to manage connections:
>>           config.maxIdle=10;
>>           config.minIdle=5;
>>           config.timeBetweenEvictionRunsMillis=1000;
>>           config.minEvictableIdleTimeMillis=1000;
>>
>> The first two force the pool to try to keep the number of idle 
>> connections between 5 and 10, which is going to force it to close / 
>> open frequently to stay within that relatively narrow range.   Unless 
>> you really need both of these, I would recommend eliminating one or 
>> both of them.
>>
>> The second two are probably the source of your problem.  These 
>> parameters are specified in milliseconds (thousandths of a second).  
>> The first one tells the pool to kick off an evictor run every second 
>> and the second tells it to destroy any connections that sit idle for 
>> more than a second.  This will create lots of connection churn and 
>> also pool access contention as the idle object evictor runs every 
>> second and closes connections that have been idle and then tries to 
>> create new ones to reach minIdle.  You should either increase both of 
>> these by at least an order of magnitude or drop  them.   Unless you 
>> really want to close connections that have been idle in the pool for 
>> longer than a specified idle timeout, I would drop these.
>>
>> Phil
>>
>>
>>
>>
>>>
>>> All best,
>>>
>>> Martin
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: user-help@commons.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: DBCP problem with idle object

Posted by Martin Dyulgerov <ne...@gmail.com>.
Hello again group!

Phil: I followed your advice and remove some of the configuration lines 
for my pool, here is the configuration i use at the moment:

GenericObjectPool.Config config=new GenericObjectPool.Config();
config.maxActive=15;
config.maxWait=1000;
config.testOnBorrow=true;

and still i get the following error:

"Exception: Cannot get a connection, pool error Timeout waiting for idle 
object SQL Exception Connection is closed. SQLException Connection is 
closed."

MySQL shows that there are active 19 connections (19 rows in set (0.00 
sec)) as a result of "mysql> SHOW FULL PROCESSLIST\G; "... When i begin 
to work on my application (about 3 hours earlier today), there were only 
6 connections, and then, at some point they increment to that number (i 
am more than sure that no one is using the application besides me, and 
all the connections use the same database as my application - so they 
have to belong to it, to the pool) My application is running for about 7 
hours to this moment after i made the changes and restarted it. Can you 
please help me with some suggestions onconfiguring the pool wright... I 
am getting pretty desperate by now :( Thanks in advance!

Martin

Phil Steitz wrote:
> Martin Dyulgerov wrote:
>> Hello group!
>>
>> This is the first time i actuali write something in here. First of 
>> all - please excuse my bad english, it is not my native language. Now 
>> to get to the point... I have problems implementing DBCP on my Tomcat 
>> 6.0.18 in my web applications. I don't want to use JNDI, that is why 
>> i have ServletContextListener, in witch i do as follows in order:
>>
>> 1.Define GenericObject Pool
>> 2. Define ConnectionFactory as implementation of 
>> DriverManagerConnectionFactory
>> 3.Define PoolableConnectionFactory with the previously created 
>> GenericObjectPool and ConnectionFactory
>> 4.Define PoolingDataSource with the GenericObjectPool object from step 1
>>
>> Then i "stick" my PoolingDataSource to the servlet context, retreive 
>> it in my JSPs and servlets and aquire a connection via 
>> "getConnection()" (which returns Connection object). I make sure to 
>> close() all my connections at the edn of the pages...I am sure that 
>> the connections that are opened dont exceed the number 100 (which is 
>> the maximum number of connections on my database - a MySQL database 
>> system), so i think there must be something wrong with my pooling 
>> code. The exact error i get is:
>>
>> "Exception: Cannot get a connection, pool error Timeout waiting for 
>> idle object SQL Exception Connection is closed. SQLException 
>> Connection is closed." At some point i began to ask myself if it the 
>> problem is caused by the restarts(reloads) i do for that exact 
>> application, because the other work fine (byt i dont play with them 
>> that much)... My configurations for the GenericObjectPool and 
>> DriverManagerConnectionFactory are as follows:
>>
>> GenericObjectPool.Config config=new GenericObjectPool.Config();
>>            config.maxActive=15;
>>            config.maxIdle=10;
>>            config.minIdle=5;
>>            config.maxWait=3000;
>>            config.testOnBorrow=true;
>>            config.testOnReturn=true;
>>            config.testWhileIdle=true;
>>            config.timeBetweenEvictionRunsMillis=1000;
>>            config.minEvictableIdleTimeMillis=1000;
>>
>> Properties p=new Properties();
>>            p.setProperty("user", user);
>>            p.setProperty("password", password);
>>            p.setProperty("useUnicode", "true");
>>            p.setProperty("characterEncoding", "CP1251");
>>            p.setProperty("autoReconnect", "true");
>>
>> Can You help me please? Any help will be appriciated. Thanks in 
>> advance, and accept my apologies if i have breaked some rules of the 
>> group or something like that.
> These settings make it hard for the pool to manage connections:
>           config.maxIdle=10;
>           config.minIdle=5;
>           config.timeBetweenEvictionRunsMillis=1000;
>           config.minEvictableIdleTimeMillis=1000;
>
> The first two force the pool to try to keep the number of idle 
> connections between 5 and 10, which is going to force it to close / 
> open frequently to stay within that relatively narrow range.   Unless 
> you really need both of these, I would recommend eliminating one or 
> both of them.
>
> The second two are probably the source of your problem.  These 
> parameters are specified in milliseconds (thousandths of a second).  
> The first one tells the pool to kick off an evictor run every second 
> and the second tells it to destroy any connections that sit idle for 
> more than a second.  This will create lots of connection churn and 
> also pool access contention as the idle object evictor runs every 
> second and closes connections that have been idle and then tries to 
> create new ones to reach minIdle.  You should either increase both of 
> these by at least an order of magnitude or drop  them.   Unless you 
> really want to close connections that have been idle in the pool for 
> longer than a specified idle timeout, I would drop these.
>
> Phil
>
>
>
>
>>
>> All best,
>>
>> Martin
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>



Re: DBCP problem with idle object

Posted by Phil Steitz <ph...@gmail.com>.
Martin Dyulgerov wrote:
> Hello group!
>
> This is the first time i actuali write something in here. First of all 
> - please excuse my bad english, it is not my native language. Now to 
> get to the point... I have problems implementing DBCP on my Tomcat 
> 6.0.18 in my web applications. I don't want to use JNDI, that is why i 
> have ServletContextListener, in witch i do as follows in order:
>
> 1.Define GenericObject Pool
> 2. Define ConnectionFactory as implementation of 
> DriverManagerConnectionFactory
> 3.Define PoolableConnectionFactory with the previously created 
> GenericObjectPool and ConnectionFactory
> 4.Define PoolingDataSource with the GenericObjectPool object from step 1
>
> Then i "stick" my PoolingDataSource to the servlet context, retreive 
> it in my JSPs and servlets and aquire a connection via 
> "getConnection()" (which returns Connection object). I make sure to 
> close() all my connections at the edn of the pages...I am sure that 
> the connections that are opened dont exceed the number 100 (which is 
> the maximum number of connections on my database - a MySQL database 
> system), so i think there must be something wrong with my pooling 
> code. The exact error i get is:
>
> "Exception: Cannot get a connection, pool error Timeout waiting for 
> idle object SQL Exception Connection is closed. SQLException 
> Connection is closed." At some point i began to ask myself if it the 
> problem is caused by the restarts(reloads) i do for that exact 
> application, because the other work fine (byt i dont play with them 
> that much)... My configurations for the GenericObjectPool and 
> DriverManagerConnectionFactory are as follows:
>
> GenericObjectPool.Config config=new GenericObjectPool.Config();
>            config.maxActive=15;
>            config.maxIdle=10;
>            config.minIdle=5;
>            config.maxWait=3000;
>            config.testOnBorrow=true;
>            config.testOnReturn=true;
>            config.testWhileIdle=true;
>            config.timeBetweenEvictionRunsMillis=1000;
>            config.minEvictableIdleTimeMillis=1000;
>
> Properties p=new Properties();
>            p.setProperty("user", user);
>            p.setProperty("password", password);
>            p.setProperty("useUnicode", "true");
>            p.setProperty("characterEncoding", "CP1251");
>            p.setProperty("autoReconnect", "true");
>
> Can You help me please? Any help will be appriciated. Thanks in 
> advance, and accept my apologies if i have breaked some rules of the 
> group or something like that.
These settings make it hard for the pool to manage connections:
           config.maxIdle=10;
           config.minIdle=5;
           config.timeBetweenEvictionRunsMillis=1000;
           config.minEvictableIdleTimeMillis=1000;

The first two force the pool to try to keep the number of idle 
connections between 5 and 10, which is going to force it to close / open 
frequently to stay within that relatively narrow range.   Unless you 
really need both of these, I would recommend eliminating one or both of 
them.

The second two are probably the source of your problem.  These 
parameters are specified in milliseconds (thousandths of a second).  The 
first one tells the pool to kick off an evictor run every second and the 
second tells it to destroy any connections that sit idle for more than a 
second.  This will create lots of connection churn and also pool access 
contention as the idle object evictor runs every second and closes 
connections that have been idle and then tries to create new ones to 
reach minIdle.  You should either increase both of these by at least an 
order of magnitude or drop  them.   Unless you really want to close 
connections that have been idle in the pool for longer than a specified 
idle timeout, I would drop these.

Phil




>
> All best,
>
> Martin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: DBCP problem with idle object

Posted by Martin Dyulgerov <ne...@gmail.com>.
Hello Clark!

Yes, i am pretty sure MySQL is configuret with amaximum of 100 active 
connections,here is the last row of the result givenby the querry which 
shows my active connections at the time:
*************************** 56. row ***************************
     Id: 1418489
   User: <my userhere>
   Host: <host:port>
     db: <my database>
Command: Query
   Time: 0
  State: Writing to net
   Info: SET NAMES cp1251
56 rows in set (0.00 sec)

There are only 56 connectionsand not all of them are forthe problematic 
application i am talking about. Why do i have to increase the number of 
connections, if there is only one user of the application - 
myselftesting it? I'll try and remove the OnReturn and testWhileIdle, 
thanks forthe suggestion. But i don't think this is the problem. Thanks 
again anyway.

Wish You all best!

Martin

Wes Clark wrote:
> You say you might have up to 100 active connections, but you only
> configure for 15.  Are you sure you don't just need to increase the
> number of active connections?  Also, if you test of borrow, I don't
> think you need to test on return or test on idle. 
>
> -----Original Message-----
> From: Martin Dyulgerov [mailto:newadminbg@gmail.com] 
> Sent: Monday, December 01, 2008 9:18 AM
> To: user@commons.apache.org
> Subject: DBCP problem with idle object
>
> Hello group!
>
> This is the first time i actuali write something in here. First of all -
> please excuse my bad english, it is not my native language. Now to get
> to the point... I have problems implementing DBCP on my Tomcat 6.0.18 in
> my web applications. I don't want to use JNDI, that is why i have
> ServletContextListener, in witch i do as follows in order:
>
> 1.Define GenericObject Pool
> 2. Define ConnectionFactory as implementation of
> DriverManagerConnectionFactory 3.Define PoolableConnectionFactory with
> the previously created GenericObjectPool and ConnectionFactory 4.Define
> PoolingDataSource with the GenericObjectPool object from step 1
>
> Then i "stick" my PoolingDataSource to the servlet context, retreive it
> in my JSPs and servlets and aquire a connection via "getConnection()" 
> (which returns Connection object). I make sure to close() all my
> connections at the edn of the pages...I am sure that the connections
> that are opened dont exceed the number 100 (which is the maximum number
> of connections on my database - a MySQL database system), so i think
> there must be something wrong with my pooling code. The exact error i
> get is:
>
> "Exception: Cannot get a connection, pool error Timeout waiting for idle
> object SQL Exception Connection is closed. SQLException Connection is
> closed." At some point i began to ask myself if it the problem is caused
> by the restarts(reloads) i do for that exact application, because the
> other work fine (byt i dont play with them that much)... My
> configurations for the GenericObjectPool and
> DriverManagerConnectionFactory are as follows:
>
> GenericObjectPool.Config config=new GenericObjectPool.Config();
>             config.maxActive=15;
>             config.maxIdle=10;
>             config.minIdle=5;
>             config.maxWait=3000;
>             config.testOnBorrow=true;
>             config.testOnReturn=true;
>             config.testWhileIdle=true;
>             config.timeBetweenEvictionRunsMillis=1000;
>             config.minEvictableIdleTimeMillis=1000;
>
> Properties p=new Properties();
>             p.setProperty("user", user);
>             p.setProperty("password", password);
>             p.setProperty("useUnicode", "true");
>             p.setProperty("characterEncoding", "CP1251");
>             p.setProperty("autoReconnect", "true");
>
> Can You help me please? Any help will be appriciated. Thanks in advance,
> and accept my apologies if i have breaked some rules of the group or
> something like that.
>
> All best,
>
> Martin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


RE: DBCP problem with idle object

Posted by Wes Clark <wc...@guidewire.com>.
You say you might have up to 100 active connections, but you only
configure for 15.  Are you sure you don't just need to increase the
number of active connections?  Also, if you test of borrow, I don't
think you need to test on return or test on idle. 

-----Original Message-----
From: Martin Dyulgerov [mailto:newadminbg@gmail.com] 
Sent: Monday, December 01, 2008 9:18 AM
To: user@commons.apache.org
Subject: DBCP problem with idle object

Hello group!

This is the first time i actuali write something in here. First of all -
please excuse my bad english, it is not my native language. Now to get
to the point... I have problems implementing DBCP on my Tomcat 6.0.18 in
my web applications. I don't want to use JNDI, that is why i have
ServletContextListener, in witch i do as follows in order:

1.Define GenericObject Pool
2. Define ConnectionFactory as implementation of
DriverManagerConnectionFactory 3.Define PoolableConnectionFactory with
the previously created GenericObjectPool and ConnectionFactory 4.Define
PoolingDataSource with the GenericObjectPool object from step 1

Then i "stick" my PoolingDataSource to the servlet context, retreive it
in my JSPs and servlets and aquire a connection via "getConnection()" 
(which returns Connection object). I make sure to close() all my
connections at the edn of the pages...I am sure that the connections
that are opened dont exceed the number 100 (which is the maximum number
of connections on my database - a MySQL database system), so i think
there must be something wrong with my pooling code. The exact error i
get is:

"Exception: Cannot get a connection, pool error Timeout waiting for idle
object SQL Exception Connection is closed. SQLException Connection is
closed." At some point i began to ask myself if it the problem is caused
by the restarts(reloads) i do for that exact application, because the
other work fine (byt i dont play with them that much)... My
configurations for the GenericObjectPool and
DriverManagerConnectionFactory are as follows:

GenericObjectPool.Config config=new GenericObjectPool.Config();
            config.maxActive=15;
            config.maxIdle=10;
            config.minIdle=5;
            config.maxWait=3000;
            config.testOnBorrow=true;
            config.testOnReturn=true;
            config.testWhileIdle=true;
            config.timeBetweenEvictionRunsMillis=1000;
            config.minEvictableIdleTimeMillis=1000;

Properties p=new Properties();
            p.setProperty("user", user);
            p.setProperty("password", password);
            p.setProperty("useUnicode", "true");
            p.setProperty("characterEncoding", "CP1251");
            p.setProperty("autoReconnect", "true");

Can You help me please? Any help will be appriciated. Thanks in advance,
and accept my apologies if i have breaked some rules of the group or
something like that.

All best,

Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org