You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Swaminathan Gurumoorthy <sw...@yahoo.com> on 2003/12/02 18:07:48 UTC
DBCP Pool - Releasing connections
I need some help on how to refresh DB connection using DBCP. We have a web application built on Struts running on Tomcat 4.1.18 and talking to a AS400 database. We use commons DBCP for datasoures.
Our database goes down every morning at 5 AM for maintenanace because of which Tomcat/DBCP loses its connection. When I come in the morning and try to access the app ,I usually get a connection exception because datasource.getConnection() craps out. I usually restart Tomcat to refresh all connections ( the project is still under development and hence I get away with it).
Is there a parameter setting by which I can ask DBCP to see if the connection is stale (like in the case of a DB shutdown) and if so release all connections or even better try 'n' times to refresh before releasing them?
Intuitively I thought the 'minIdle=0' wud do the trick but it is set to zero by default anyway. Will setting removeAbandoned to true help my cause?
TIA.
Swami
---------------------------------
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
Re: DBCP Pool - Releasing connections
Posted by Dirk Verbeeck <di...@pandora.be>.
All the test* properties require the validation parameter to be set.
Test while idle does the test in background if the overhead of testOnBorrow is
too large.
But your best bet is to close the datasource like Larry suggested
or to restart when the database is available again .
-- Dirk
Swaminathan Gurumoorthy wrote:
> Can I use 'testOnBorrow' to validate the connection. The documentaion says it is 'true' by default. Will this parameter work only with 'validationQuery '?
>
> I wish DBCP has a 'releaseStale' parameter similar to the 'removeAbandoned' . This may eliminate the overhead on 'testOnBorrow'.
>
> TIA
> Swami
>
> Larry Young <ly...@dalmatian.com> wrote:
> Swami,
>
> When I detect a problem like this in my code, I call "close()" on
> the datasource, which in my case is a BasicDataSource. This blows away all
> currently held connections in the pool. If you're in a multi-threaded
> world like in a web app, you might want to be a bit careful of how you do
> this to avoid any race conditions, although if one connection is dead, more
> than likely they all will be.
>
> Another thing that I do is I have an agreement with our AS400 DB
> folks that when they are going down, they send me a message so I can handle
> this type of behavior a bit more gracefully.
>
> --- regards ---
> Larry
>
>
> At 10:07 AM 12/2/03, you wrote:
>
>>I need some help on how to refresh DB connection using DBCP. We have a web
>>application built on Struts running on Tomcat 4.1.18 and talking to a
>>AS400 database. We use commons DBCP for datasoures.
>>
>>Our database goes down every morning at 5 AM for maintenanace because of
>>which Tomcat/DBCP loses its connection. When I come in the morning and
>>try to access the app ,I usually get a connection exception because
>>datasource.getConnection() craps out. I usually restart Tomcat to refresh
>>all connections ( the project is still under development and hence I get
>>away with it).
>>
>>Is there a parameter setting by which I can ask DBCP to see if the
>>connection is stale (like in the case of a DB shutdown) and if so release
>>all connections or even better try 'n' times to refresh before releasing them?
>>
>>Intuitively I thought the 'minIdle=0' wud do the trick but it is set to
>>zero by default anyway. Will setting removeAbandoned to true help my cause?
>>
>>TIA.
>>Swami
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: DBCP Pool - Releasing connections
Posted by Swaminathan Gurumoorthy <sw...@yahoo.com>.
Can I use 'testOnBorrow' to validate the connection. The documentaion says it is 'true' by default. Will this parameter work only with 'validationQuery '?
I wish DBCP has a 'releaseStale' parameter similar to the 'removeAbandoned' . This may eliminate the overhead on 'testOnBorrow'.
TIA
Swami
Larry Young <ly...@dalmatian.com> wrote:
Swami,
When I detect a problem like this in my code, I call "close()" on
the datasource, which in my case is a BasicDataSource. This blows away all
currently held connections in the pool. If you're in a multi-threaded
world like in a web app, you might want to be a bit careful of how you do
this to avoid any race conditions, although if one connection is dead, more
than likely they all will be.
Another thing that I do is I have an agreement with our AS400 DB
folks that when they are going down, they send me a message so I can handle
this type of behavior a bit more gracefully.
--- regards ---
Larry
At 10:07 AM 12/2/03, you wrote:
>I need some help on how to refresh DB connection using DBCP. We have a web
>application built on Struts running on Tomcat 4.1.18 and talking to a
>AS400 database. We use commons DBCP for datasoures.
>
>Our database goes down every morning at 5 AM for maintenanace because of
>which Tomcat/DBCP loses its connection. When I come in the morning and
>try to access the app ,I usually get a connection exception because
>datasource.getConnection() craps out. I usually restart Tomcat to refresh
>all connections ( the project is still under development and hence I get
>away with it).
>
>Is there a parameter setting by which I can ask DBCP to see if the
>connection is stale (like in the case of a DB shutdown) and if so release
>all connections or even better try 'n' times to refresh before releasing them?
>
>Intuitively I thought the 'minIdle=0' wud do the trick but it is set to
>zero by default anyway. Will setting removeAbandoned to true help my cause?
>
>TIA.
>Swami
>
>
>
>
>---------------------------------
>Do you Yahoo!?
>Free Pop-Up Blocker - Get it now
--------------------------
Larry Young
The Dalmatian Group
www.dalmatian.com
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
---------------------------------
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
Re: DBCP Pool - Releasing connections
Posted by Larry Young <ly...@dalmatian.com>.
Swami,
When I detect a problem like this in my code, I call "close()" on
the datasource, which in my case is a BasicDataSource. This blows away all
currently held connections in the pool. If you're in a multi-threaded
world like in a web app, you might want to be a bit careful of how you do
this to avoid any race conditions, although if one connection is dead, more
than likely they all will be.
Another thing that I do is I have an agreement with our AS400 DB
folks that when they are going down, they send me a message so I can handle
this type of behavior a bit more gracefully.
--- regards ---
Larry
At 10:07 AM 12/2/03, you wrote:
>I need some help on how to refresh DB connection using DBCP. We have a web
>application built on Struts running on Tomcat 4.1.18 and talking to a
>AS400 database. We use commons DBCP for datasoures.
>
>Our database goes down every morning at 5 AM for maintenanace because of
>which Tomcat/DBCP loses its connection. When I come in the morning and
>try to access the app ,I usually get a connection exception because
>datasource.getConnection() craps out. I usually restart Tomcat to refresh
>all connections ( the project is still under development and hence I get
>away with it).
>
>Is there a parameter setting by which I can ask DBCP to see if the
>connection is stale (like in the case of a DB shutdown) and if so release
>all connections or even better try 'n' times to refresh before releasing them?
>
>Intuitively I thought the 'minIdle=0' wud do the trick but it is set to
>zero by default anyway. Will setting removeAbandoned to true help my cause?
>
>TIA.
>Swami
>
>
>
>
>---------------------------------
>Do you Yahoo!?
>Free Pop-Up Blocker - Get it now
--------------------------
Larry Young
The Dalmatian Group
www.dalmatian.com
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org