You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Dave, Tushar" <tu...@employease.com> on 2007/08/07 16:42:38 UTC

[DBCP] Connection gets blocked on 9th connection.

I am initializing the GeneriConnectionPool using the following
parameters

 

MaxActive=3D30

MaxIdle=3D20

MinIdle=3D20

MaxWait=3D1000

TestOnBorrow=3Dtrue

ActionWhenExhasuted =3D 2(GROW)

 

I try to test the connection pool by using the following code.

 

List<Connection> liCon =3D new ArrayList<Connection>(); for(i=3D0 ; i <
10 ; i++) {

      Connection oCon =3D oPool.getConnection();

      liCon.add(oCon);

}

 

The call to oPool.getConnection() gets blocked indefinitely when I try
to get the 9th connection.

 

Am I missing something?

Any ideas

 

Thanks

Tushar Dave

 

 

 


Re: [DBCP] Connection gets blocked on 9th connection.

Posted by Antonio Petrelli <an...@gmail.com>.
2007/8/7, Dave, Tushar <tu...@employease.com>:
> The call to oPool.getConnection() gets blocked indefinitely when I try
> to get the 9th connection.
> Am I missing something?

It's the normal behaviour! You have to close the connection when finished!

Antonio

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


RE: unsubscribe

Posted by Jörg Schaible <Jo...@Elsag-Solutions.com>.
Read dude, READ!!

Shukla, Sandeep wrote on Thursday, August 09, 2007 8:12 AM:

> unsubscribe
> 
> Thanks & Regards
> 
> Sandeep Shukla.
> REALResolution Development.

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


unsubscribe

Posted by "Shukla, Sandeep" <Sa...@ocwen.com>.
unsubscribe

Thanks & Regards
 
Sandeep Shukla.
REALResolution Development.
 

-----Original Message-----
From: Phil Steitz [mailto:phil.steitz@gmail.com] 
Sent: Thursday, August 09, 2007 11:40 AM
To: Jakarta Commons Developers List
Subject: Re: [DBCP] Connection gets blocked on 9th connection.

On 8/8/07, Dave, Tushar <tu...@employease.com> wrote:
> Thanks a lot Phil.
>
> I am using the DriverManagerConnectionFactory instead of
> DataSourceConnectionFactory and it works fine.
>
> BasicDataSource does not have an option to specify the
> When Exhausted Action. If I use BasicDataSource then how can I specify
> this parameter.
>
You can't set this pool parameter using BasicDataSource directly.  If
you really need to change the default (WHEN_EXHAUSTED_BLOCK), then you
either have to follow the pattern in the
ManualPoolingDataSourceExample, creating the pool yourself and setting
its properties before using it to create a PoolingDataSource, or
subclass BasicDataSource and add a setter that sets this property on
the (protected) connectionPool member.

Phil

 Original Message-----
> From: Phil Steitz [mailto:phil.steitz@gmail.com]
> Sent: Tuesday, August 07, 2007 8:13 PM
> To: Jakarta Commons Developers List
> Subject: Re: [DBCP] Connection gets blocked on 9th connection.
>
> Tushar,
>
> If you want to use BasicDataSource, you need to set the pool
> properties using its setters (i.e., using the setters on the
> BasicDataSource instance).  It is designed to take care of creating
> and managing the underlying pool and PoolingDataSource for you.
>
> Have a look at the examples here:
>
> http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/doc/
>
> The BasicDataSourceExample defaults the pool parameters, but
> ds.setMaxIdle, etc could be added to the setupDataSource method there
> to set those parameters.
>
> The ManualPoolingDataSourceExample shows how to do it if you want to
> create the pool yourself and "manually" create the PoolingDataSource
> from it.
>
> Phil
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

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



********************************************************************************************************

This E-mail message and its attachments, if any are intended solely for the use of the addressee hereof. In addition, this message and the attachments, if any may contain information that is confidential, privileged and exempt from disclosure under applicable law. If you are not the intended recipient of this message, you are prohibited from reading, disclosing, reproducing, distributing, disseminating or otherwise using this transmission.


Delivery of this message to any person other than the intended recipient is not intended to waive any right or privilege. If you have received this message in error, please promptly notify the sender by reply E-mail and immediately delete this message from your system. Instructions transmitted over this system are not binding on us until they are confirmed by us. Message transmission is not guaranteed to be secure or free of software virus. While Ocwen Financial Corporation and its subsidiaries collectively "Ocwen" takes every reasonable precaution to minimize such risks, Ocwen cannot accept liability for any damage sustained by you or any third party as a result of software viruses.

**************************************************************************************************


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


Re: [DBCP] Connection gets blocked on 9th connection.

Posted by Phil Steitz <ph...@gmail.com>.
On 8/8/07, Dave, Tushar <tu...@employease.com> wrote:
> Thanks a lot Phil.
>
> I am using the DriverManagerConnectionFactory instead of
> DataSourceConnectionFactory and it works fine.
>
> BasicDataSource does not have an option to specify the
> When Exhausted Action. If I use BasicDataSource then how can I specify
> this parameter.
>
You can't set this pool parameter using BasicDataSource directly.  If
you really need to change the default (WHEN_EXHAUSTED_BLOCK), then you
either have to follow the pattern in the
ManualPoolingDataSourceExample, creating the pool yourself and setting
its properties before using it to create a PoolingDataSource, or
subclass BasicDataSource and add a setter that sets this property on
the (protected) connectionPool member.

Phil

 Original Message-----
> From: Phil Steitz [mailto:phil.steitz@gmail.com]
> Sent: Tuesday, August 07, 2007 8:13 PM
> To: Jakarta Commons Developers List
> Subject: Re: [DBCP] Connection gets blocked on 9th connection.
>
> Tushar,
>
> If you want to use BasicDataSource, you need to set the pool
> properties using its setters (i.e., using the setters on the
> BasicDataSource instance).  It is designed to take care of creating
> and managing the underlying pool and PoolingDataSource for you.
>
> Have a look at the examples here:
>
> http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/doc/
>
> The BasicDataSourceExample defaults the pool parameters, but
> ds.setMaxIdle, etc could be added to the setupDataSource method there
> to set those parameters.
>
> The ManualPoolingDataSourceExample shows how to do it if you want to
> create the pool yourself and "manually" create the PoolingDataSource
> from it.
>
> Phil
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

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


RE: [DBCP] Connection gets blocked on 9th connection.

Posted by "Dave, Tushar" <tu...@employease.com>.
Thanks a lot Phil.

I am using the DriverManagerConnectionFactory instead of 
DataSourceConnectionFactory and it works fine. 

BasicDataSource does not have an option to specify the
When Exhausted Action. If I use BasicDataSource then how can I specify
this parameter.



-----Original Message-----
From: Phil Steitz [mailto:phil.steitz@gmail.com] 
Sent: Tuesday, August 07, 2007 8:13 PM
To: Jakarta Commons Developers List
Subject: Re: [DBCP] Connection gets blocked on 9th connection.

Tushar,

If you want to use BasicDataSource, you need to set the pool
properties using its setters (i.e., using the setters on the
BasicDataSource instance).  It is designed to take care of creating
and managing the underlying pool and PoolingDataSource for you.

Have a look at the examples here:

http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/doc/

The BasicDataSourceExample defaults the pool parameters, but
ds.setMaxIdle, etc could be added to the setupDataSource method there
to set those parameters.

The ManualPoolingDataSourceExample shows how to do it if you want to
create the pool yourself and "manually" create the PoolingDataSource
from it.

Phil

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


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


Re: [DBCP] Connection gets blocked on 9th connection.

Posted by Phil Steitz <ph...@gmail.com>.
Tushar,

If you want to use BasicDataSource, you need to set the pool
properties using its setters (i.e., using the setters on the
BasicDataSource instance).  It is designed to take care of creating
and managing the underlying pool and PoolingDataSource for you.

Have a look at the examples here:

http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/doc/

The BasicDataSourceExample defaults the pool parameters, but
ds.setMaxIdle, etc could be added to the setupDataSource method there
to set those parameters.

The ManualPoolingDataSourceExample shows how to do it if you want to
create the pool yourself and "manually" create the PoolingDataSource
from it.

Phil

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


RE: [DBCP] Connection gets blocked on 9th connection.

Posted by "Dave, Tushar" <tu...@employease.com>.
I use following settings.
DRIVER : com.informix.jdbc.IfxDriver
URL:
jdbc:Informix:sqli://host_ip:1557/db:INFORMIXSERVER=dbserver;user=userna
me;password=password;lobcache=-1;fet_buf_size=32767;optofc=1;ifx_autofre
e=true;
MaxPoolSize = 30
MaxIdle =20
MinIdle = 20
MaxWait = 1000
Test on Borrow = true;
When Exhuasted Action = 2 ( WHEN_EXHAUSTED_GROW )
Validation SQL = select 1 from test_table


By looking more through the debug the call to
BasicDataSource.getConnection()  calls createDataSource() which creates
a new GenericObjectPool and PoolableDataSource. The default MaxPoolSIze
for GenericObjectPool is 8 hence it fails to get the 9th connection.

Seems I am not initializing the pool properly?
Can someone give me some pointers on how I can use BasicDataSource with
GenericObjectPool.

Thanks
Tushar Dave






-----Original Message-----
From: Sergey Vladimirov [mailto:vlsergey@gmail.com] 
Sent: Tuesday, August 07, 2007 4:44 PM
To: Jakarta Commons Developers List
Subject: Re: [DBCP] Connection gets blocked on 9th connection.

Dave,

What Driver / database / settings are you using?

It seems there is underlying connection pol which prevents you from
obtaining 9th connection.

Sergey.


2007/8/7, Dave, Tushar <tu...@employease.com>:
>
> I am initializing the Pool as below.
>
> private void initialize(ConnectionPoolParameters oParams)
> {
>    GenericObjectPool oPool = new GenericObjectPool(null);
>    oPool.setMaxActive(oParams.getMaxSize());
>    oPool.setMaxIdle (oParams.getMinSize ());
>    oPool.setMinIdle(oParams.getMinSize());
>    oPool.setMaxWait(oParams.getTimeout());
>    oPool.setTestOnBorrow(true);
>
>    setWhenExhaustedAction(oParams.getExhaustAction());
>
>    BasicDataSource oDataSource = new BasicDataSource();
>    oDataSource.setDriverClassName(oParams.getDriver());
>    oDataSource.setUrl(oParams.getJdbcUrl());
>    oDataSource.setValidationQuery(oParams.getConnectionTest());
>
>    ConnectionFactory oFactory = new
> DataSourceConnectionFactory(oDataSource);
>
>    PoolableConnectionFactory oPoolFactory =
>      new PoolableConnectionFactory(oFactory, this, null,
> oParams.getConnectionTest (), false, true);
>
>    _oDataSource = new PoolingDataSource(this);
>    _bEnabled = true;
> }
> It seems that BasicDataSource creates its own Pool and
> PoolableConnectionFactory and it has the default settings of the Pool
> (maxSize=8).
> So If I specified 30 as the max connections it still thinks 8 as the
max
> connections.
>
> Am I initializing the pool properly?
>
> --Tushar
>
>
>
>
>
> ________________________________
>
> From: Dave, Tushar
> Sent: Tuesday, August 07, 2007 10:43 AM
> To: 'commons-dev@jakarta.apache.org'
> Subject: [DBCP] Connection gets blocked on 9th connection.
>
>
>
> I am initializing the GeneriConnectionPool using the following
> parameters
>
>
>
> MaxActive=30
>
> MaxIdle=20
>
> MinIdle=20
>
> MaxWait=1000
>
> TestOnBorrow=true
>
> ActionWhenExhasuted =2(GROW)
>
>
>
> I try to test the connection pool by using the following code.
>
>
>
> List<Connection> liCon = new ArrayList<Connection>();
>
>
>
> for(i=0 ; i < 10 ; i++) {
>
>      Connection oCon = oPool.getConnection();
>
>      liCon.add(oCon);
>
> }
>
>
>
> The call to oPool.getConnection() gets blocked indefinitely when I try
> to get the 9th connection.
>
>
>
> Am I missing something?
>
> Any ideas
>
>
>
> Thanks
>
> Tushar Dave
>
>
>
>
>
>
>
>


-- 
Sergey Vladimirov

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


Re: [DBCP] Connection gets blocked on 9th connection.

Posted by Sergey Vladimirov <vl...@gmail.com>.
Dave,

What Driver / database / settings are you using?

It seems there is underlying connection pol which prevents you from
obtaining 9th connection.

Sergey.


2007/8/7, Dave, Tushar <tu...@employease.com>:
>
> I am initializing the Pool as below.
>
> private void initialize(ConnectionPoolParameters oParams)
> {
>    GenericObjectPool oPool = new GenericObjectPool(null);
>    oPool.setMaxActive(oParams.getMaxSize());
>    oPool.setMaxIdle (oParams.getMinSize ());
>    oPool.setMinIdle(oParams.getMinSize());
>    oPool.setMaxWait(oParams.getTimeout());
>    oPool.setTestOnBorrow(true);
>
>    setWhenExhaustedAction(oParams.getExhaustAction());
>
>    BasicDataSource oDataSource = new BasicDataSource();
>    oDataSource.setDriverClassName(oParams.getDriver());
>    oDataSource.setUrl(oParams.getJdbcUrl());
>    oDataSource.setValidationQuery(oParams.getConnectionTest());
>
>    ConnectionFactory oFactory = new
> DataSourceConnectionFactory(oDataSource);
>
>    PoolableConnectionFactory oPoolFactory =
>      new PoolableConnectionFactory(oFactory, this, null,
> oParams.getConnectionTest (), false, true);
>
>    _oDataSource = new PoolingDataSource(this);
>    _bEnabled = true;
> }
> It seems that BasicDataSource creates its own Pool and
> PoolableConnectionFactory and it has the default settings of the Pool
> (maxSize=8).
> So If I specified 30 as the max connections it still thinks 8 as the max
> connections.
>
> Am I initializing the pool properly?
>
> --Tushar
>
>
>
>
>
> ________________________________
>
> From: Dave, Tushar
> Sent: Tuesday, August 07, 2007 10:43 AM
> To: 'commons-dev@jakarta.apache.org'
> Subject: [DBCP] Connection gets blocked on 9th connection.
>
>
>
> I am initializing the GeneriConnectionPool using the following
> parameters
>
>
>
> MaxActive=30
>
> MaxIdle=20
>
> MinIdle=20
>
> MaxWait=1000
>
> TestOnBorrow=true
>
> ActionWhenExhasuted =2(GROW)
>
>
>
> I try to test the connection pool by using the following code.
>
>
>
> List<Connection> liCon = new ArrayList<Connection>();
>
>
>
> for(i=0 ; i < 10 ; i++) {
>
>      Connection oCon = oPool.getConnection();
>
>      liCon.add(oCon);
>
> }
>
>
>
> The call to oPool.getConnection() gets blocked indefinitely when I try
> to get the 9th connection.
>
>
>
> Am I missing something?
>
> Any ideas
>
>
>
> Thanks
>
> Tushar Dave
>
>
>
>
>
>
>
>


-- 
Sergey Vladimirov

RE: [DBCP] Connection gets blocked on 9th connection.

Posted by "Dave, Tushar" <tu...@employease.com>.
I am initializing the Pool as below.
 
private void initialize(ConnectionPoolParameters oParams)
  {
    GenericObjectPool oPool = new GenericObjectPool(null);
    oPool.setMaxActive(oParams.getMaxSize());
    oPool.setMaxIdle (oParams.getMinSize ());
    oPool.setMinIdle(oParams.getMinSize());
    oPool.setMaxWait(oParams.getTimeout());
    oPool.setTestOnBorrow(true);
        
    setWhenExhaustedAction(oParams.getExhaustAction());
       
    BasicDataSource oDataSource = new BasicDataSource();
    oDataSource.setDriverClassName(oParams.getDriver());
    oDataSource.setUrl(oParams.getJdbcUrl());
    oDataSource.setValidationQuery(oParams.getConnectionTest());
 
    ConnectionFactory oFactory = new
DataSourceConnectionFactory(oDataSource);
    
    PoolableConnectionFactory oPoolFactory =
      new PoolableConnectionFactory(oFactory, this, null,
oParams.getConnectionTest (), false, true);
    
    _oDataSource = new PoolingDataSource(this);
    _bEnabled = true;
  }
It seems that BasicDataSource creates its own Pool and
PoolableConnectionFactory and it has the default settings of the Pool
(maxSize=8).
So If I specified 30 as the max connections it still thinks 8 as the max
connections.
 
Am I initializing the pool properly?
 
--Tushar 

 

 

________________________________

From: Dave, Tushar 
Sent: Tuesday, August 07, 2007 10:43 AM
To: 'commons-dev@jakarta.apache.org'
Subject: [DBCP] Connection gets blocked on 9th connection.

 

I am initializing the GeneriConnectionPool using the following
parameters

 

MaxActive=30

MaxIdle=20

MinIdle=20

MaxWait=1000

TestOnBorrow=true

ActionWhenExhasuted =2(GROW)

 

I try to test the connection pool by using the following code.

 

List<Connection> liCon = new ArrayList<Connection>(); 

 

for(i=0 ; i < 10 ; i++) {

      Connection oCon = oPool.getConnection();

      liCon.add(oCon);

}

 

The call to oPool.getConnection() gets blocked indefinitely when I try
to get the 9th connection.

 

Am I missing something?

Any ideas

 

Thanks

Tushar Dave