You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Pruitt, Byron S" <st...@hp.com> on 2015/09/03 18:22:56 UTC

[dbcp] new user questions

I am new to the DBCP framework and I have some newbie questions.

I have the PoolingDataSourceExample working with my driver and I get connections from my DataSource.

What I am unclear on is how I return a connection back to the pool.
After I have finished with executing a statement and finished with the ResultSet or having issued a commit if that is needed, then what?
Do I do nothing with the connection?  How is the connection returned to pool, so it can be reused?


Also, it looks like the way to configure the pool for the number of connections, etc. is via GenericObjectPoolConfig passed to the GenericObjectPool instance.



Thanks ahead for any answers.


Steve Pruitt


RE: [dbcp] new user questions

Posted by "Pruitt, Byron S" <st...@hp.com>.
Thanks.

-----Original Message-----
From: Phil Steitz [mailto:phil.steitz@gmail.com] 
Sent: Thursday, September 03, 2015 1:26 PM
To: Commons Users List
Subject: Re: [dbcp] new user questions





> On Sep 3, 2015, at 9:22 AM, Pruitt, Byron S <st...@hp.com> wrote:
> 
> I am new to the DBCP framework and I have some newbie questions.
> 
> I have the PoolingDataSourceExample working with my driver and I get connections from my DataSource.
> 
> What I am unclear on is how I return a connection back to the pool.
> After I have finished with executing a statement and finished with the ResultSet or having issued a commit if that is needed, then what?
> Do I do nothing with the connection?  How is the connection returned to pool, so it can be reused?

Just call close() on the connection.  That will cause the physical connection to be returned to the pool.
> 
> 
> Also, it looks like the way to configure the pool for the number of connections, etc. is via GenericObjectPoolConfig passed to the GenericObjectPool instance.
> 
> 
Correct.  If you don't want to separately create and configure the object pool, have a look at BasicDatasource, which exposes the pool configure parameters directly.

Phil
> 
> Thanks ahead for any answers.
> 
> 
> Steve Pruitt
> 

---------------------------------------------------------------------
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] new user questions

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



> On Sep 3, 2015, at 9:22 AM, Pruitt, Byron S <st...@hp.com> wrote:
> 
> I am new to the DBCP framework and I have some newbie questions.
> 
> I have the PoolingDataSourceExample working with my driver and I get connections from my DataSource.
> 
> What I am unclear on is how I return a connection back to the pool.
> After I have finished with executing a statement and finished with the ResultSet or having issued a commit if that is needed, then what?
> Do I do nothing with the connection?  How is the connection returned to pool, so it can be reused?

Just call close() on the connection.  That will cause the physical connection to be returned to the pool.
> 
> 
> Also, it looks like the way to configure the pool for the number of connections, etc. is via GenericObjectPoolConfig passed to the GenericObjectPool instance.
> 
> 
Correct.  If you don't want to separately create and configure the object pool, have a look at BasicDatasource, which exposes the pool configure parameters directly.

Phil
> 
> Thanks ahead for any answers.
> 
> 
> Steve Pruitt
> 

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