You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Uctaa <du...@gmail.com> on 2007/01/08 16:48:27 UTC

How to forcibly close abandoned database connections?

Tomcat provides the removeAbandoned and removeAbandonedTimeout
parameters when setting up data sources in server.xml.  But according
to the documentation I've read, abandoned connections only get closed
and recycled when available connections run low and new connections
are requested.

Is there a way for me to forcibly close/release abandoned connections
on the server from a privileged application running on the same
server?

BTW, I'm running Tomcat 5.5 on a Windows 2003 box, running against DB2
on an iSeries box (jt400 for the JDBC driver), using Tomcat's DBCP for
the pooling.

Thanks,
David

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


Re: How to forcibly close abandoned database connections?

Posted by David Uctaa <du...@gmail.com>.
Created a little admin app to do just that, and it worked perfectly.
All the connections being shown as "busy" cleared right out, and only
the minimum number of idle / available connections remained.

Thanks much.

On 1/10/07, Varley, Roger <Ro...@atosorigin.com> wrote:
>
> >
> > I agree that is probably what is happening, since the application has
> > gone idle.  However, with garbage collection, while it will only
> > reclaim memory when necessary, there is a way to force garbage
> > collection.  I am looking for a similar process with abandoned
> > database connections.
> >
>
> If the connections will only re-cycle with increased demand, could you not create that demand with an "admin" type program that requests, opens & then closes X connections?
>
> Regards
> Roger
>
> _______________________________________________________
>
> This e-mail and the documents attached are confidential and intended
> solely for the addressee; it may also be privileged. If you receive this
> e-mail in error, please notify the sender immediately and destroy it.
> As its integrity cannot be secured on the Internet, the Atos Origin group
> liability cannot be triggered for the message content. Although the
> sender endeavours to maintain a computer virus-free network, the
> sender does not warrant that this transmission is virus-free and will
> not be liable for any damages resulting from any virus transmitted.
> _______________________________________________________
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


Re: How to forcibly close abandoned database connections?

Posted by David Uctaa <du...@gmail.com>.
Possible.  I'll give it a try...

On 1/10/07, Varley, Roger <Ro...@atosorigin.com> wrote:
>
> >
> > I agree that is probably what is happening, since the application has
> > gone idle.  However, with garbage collection, while it will only
> > reclaim memory when necessary, there is a way to force garbage
> > collection.  I am looking for a similar process with abandoned
> > database connections.
> >
>
> If the connections will only re-cycle with increased demand, could you not create that demand with an "admin" type program that requests, opens & then closes X connections?
>
> Regards
> Roger
>
> _______________________________________________________
>
> This e-mail and the documents attached are confidential and intended
> solely for the addressee; it may also be privileged. If you receive this
> e-mail in error, please notify the sender immediately and destroy it.
> As its integrity cannot be secured on the Internet, the Atos Origin group
> liability cannot be triggered for the message content. Although the
> sender endeavours to maintain a computer virus-free network, the
> sender does not warrant that this transmission is virus-free and will
> not be liable for any damages resulting from any virus transmitted.
> _______________________________________________________
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


RE: How to forcibly close abandoned database connections?

Posted by "Varley, Roger" <Ro...@atosorigin.com>.
> 
> I agree that is probably what is happening, since the application has
> gone idle.  However, with garbage collection, while it will only
> reclaim memory when necessary, there is a way to force garbage
> collection.  I am looking for a similar process with abandoned
> database connections.
> 

If the connections will only re-cycle with increased demand, could you not create that demand with an "admin" type program that requests, opens & then closes X connections?

Regards
Roger

_______________________________________________________

This e-mail and the documents attached are confidential and intended
solely for the addressee; it may also be privileged. If you receive this
e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin group
liability cannot be triggered for the message content. Although the
sender endeavours to maintain a computer virus-free network, the
sender does not warrant that this transmission is virus-free and will
not be liable for any damages resulting from any virus transmitted. 
_______________________________________________________

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


Re: How to forcibly close abandoned database connections?

Posted by David Uctaa <du...@gmail.com>.
I agree that is probably what is happening, since the application has
gone idle.  However, with garbage collection, while it will only
reclaim memory when necessary, there is a way to force garbage
collection.  I am looking for a similar process with abandoned
database connections.

On 1/10/07, EDMOND KEMOKAI <ek...@gmail.com> wrote:
> It is possible that whatever procedure is responsible for checking for
> abandoned connections only does so when there is actual need for a
> connection, similar to how a garbage collector works to reclaim memory. If
> there is no seeming stress on the connection resources then it would make
> sense not to jump the gun to look for and recycle abandoned connections. Of
> course I don't know if that is what is happening, but I suspect it might be.
>
> On 1/10/07, David Uctaa <du...@gmail.com> wrote:
> >
> > Perhaps I was unclear what it is I'm trying to do.  I have a
> > connection pool set up under Tomcat 5.5, connecting to DB2 on an
> > iSeries box using Tomcat's DBCP.  It is set up for 30 connections.  I
> > am using Lambda Probe (a great open source Tomcat monitoring app) to
> > monitor the datasources.  It is showing, let's say, that there are a
> > max of 30 connections allowed, that 11 have been "established", and 9
> > are "busy".  I know that these 9 are due to a connection pool leak bug
> > that was corrected (but not yet deployed), so even though the
> > application has gone idle and no one is using it, the connections
> > remain "busy" indefinitely.  I have enabled removeAbandoned in my
> > server.xml, but according to the Tomcat docs, abandoned connections
> > are only recycled if there is a need for them, due to the number of
> > available datasources getting low.  The number of available
> > datasources are not yet low, so these orphaned connections are still
> > being reported as "busy".  I'm a little bit anal with regard to
> > keeping things kinda clean on the server, so I would like to have
> > these abandoned connections no longer reported as "busy" once they are
> > orphaned.  Is there a way to find and recycle abandoned connections
> > forcibly?
> >
> > Thanks,
> > David
> >
> > On 1/8/07, David Uctaa <du...@gmail.com> wrote:
> > > Tomcat provides the removeAbandoned and removeAbandonedTimeout
> > > parameters when setting up data sources in server.xml.  But according
> > > to the documentation I've read, abandoned connections only get closed
> > > and recycled when available connections run low and new connections
> > > are requested.
> > >
> > > Is there a way for me to forcibly close/release abandoned connections
> > > on the server from a privileged application running on the same
> > > server?
> > >
> > > BTW, I'm running Tomcat 5.5 on a Windows 2003 box, running against DB2
> > > on an iSeries box (jt400 for the JDBC driver), using Tomcat's DBCP for
> > > the pooling.
> > >
> > > Thanks,
> > > David
> > >
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>
>
> --
> "talk trash and carry a small stick."
> PAUL KRUGMAN (NYT)
>
>

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


Re: How to forcibly close abandoned database connections?

Posted by EDMOND KEMOKAI <ek...@gmail.com>.
It is possible that whatever procedure is responsible for checking for
abandoned connections only does so when there is actual need for a
connection, similar to how a garbage collector works to reclaim memory. If
there is no seeming stress on the connection resources then it would make
sense not to jump the gun to look for and recycle abandoned connections. Of
course I don't know if that is what is happening, but I suspect it might be.

On 1/10/07, David Uctaa <du...@gmail.com> wrote:
>
> Perhaps I was unclear what it is I'm trying to do.  I have a
> connection pool set up under Tomcat 5.5, connecting to DB2 on an
> iSeries box using Tomcat's DBCP.  It is set up for 30 connections.  I
> am using Lambda Probe (a great open source Tomcat monitoring app) to
> monitor the datasources.  It is showing, let's say, that there are a
> max of 30 connections allowed, that 11 have been "established", and 9
> are "busy".  I know that these 9 are due to a connection pool leak bug
> that was corrected (but not yet deployed), so even though the
> application has gone idle and no one is using it, the connections
> remain "busy" indefinitely.  I have enabled removeAbandoned in my
> server.xml, but according to the Tomcat docs, abandoned connections
> are only recycled if there is a need for them, due to the number of
> available datasources getting low.  The number of available
> datasources are not yet low, so these orphaned connections are still
> being reported as "busy".  I'm a little bit anal with regard to
> keeping things kinda clean on the server, so I would like to have
> these abandoned connections no longer reported as "busy" once they are
> orphaned.  Is there a way to find and recycle abandoned connections
> forcibly?
>
> Thanks,
> David
>
> On 1/8/07, David Uctaa <du...@gmail.com> wrote:
> > Tomcat provides the removeAbandoned and removeAbandonedTimeout
> > parameters when setting up data sources in server.xml.  But according
> > to the documentation I've read, abandoned connections only get closed
> > and recycled when available connections run low and new connections
> > are requested.
> >
> > Is there a way for me to forcibly close/release abandoned connections
> > on the server from a privileged application running on the same
> > server?
> >
> > BTW, I'm running Tomcat 5.5 on a Windows 2003 box, running against DB2
> > on an iSeries box (jt400 for the JDBC driver), using Tomcat's DBCP for
> > the pooling.
> >
> > Thanks,
> > David
> >
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
"talk trash and carry a small stick."
PAUL KRUGMAN (NYT)

Re: How to forcibly close abandoned database connections?

Posted by David Uctaa <du...@gmail.com>.
In server.xml, within GlobalNamingResources, include something like this:

<Resource
auth="Container"
driverClassName="com.ibm.as400.access.AS400JDBCDriver"
maxActive="30"
maxIdle="2"
maxWait="5000"
name="jdbc/something"
password="password"
type="javax.sql.DataSource"
url="jdbc:as400://abc.def.com"
username="username"
removeAbandoned="true"
removeAbandonedTimeout="120"
logAbandoned="true"/>

Within the context.xml in your application's META-INF folder, include
this underneath the <Context> element:

<ResourceLink
global="jdbc/something"
name="jdbc/something"
type="javax.sql.DataSource" />

Within your appilcation code, include something like this:

InitialContext initCtx = new InitialContext();
Context ctx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) ctx.lookup("jdbc/something");
Connection con = ds.getConnection();

Make sure jt400.jar resides in your tomcat's common/lib folder

Hope this helps.




On 1/10/07, Greg Foulks <gf...@gmail.com> wrote:
> David,
> Any chance you could share with me your connection pool configuration? I've
> been struggling with trying to setup my own connection to our DB2 using the
> jt400 jar and have not been able to find any documentation for doing this
> with a DB2 connection.
>
> Thanks,
> Greg
>
>
> On 1/10/07, David Uctaa <du...@gmail.com> wrote:
> >
> > Perhaps I was unclear what it is I'm trying to do.  I have a
> > connection pool set up under Tomcat 5.5, connecting to DB2 on an
> > iSeries box using Tomcat's DBCP.  It is set up for 30 connections.  I
> > am using Lambda Probe (a great open source Tomcat monitoring app) to
> > monitor the datasources.  It is showing, let's say, that there are a
> > max of 30 connections allowed, that 11 have been "established", and 9
> > are "busy".  I know that these 9 are due to a connection pool leak bug
> > that was corrected (but not yet deployed), so even though the
> > application has gone idle and no one is using it, the connections
> > remain "busy" indefinitely.  I have enabled removeAbandoned in my
> > server.xml, but according to the Tomcat docs, abandoned connections
> > are only recycled if there is a need for them, due to the number of
> > available datasources getting low.  The number of available
> > datasources are not yet low, so these orphaned connections are still
> > being reported as "busy".  I'm a little bit anal with regard to
> > keeping things kinda clean on the server, so I would like to have
> > these abandoned connections no longer reported as "busy" once they are
> > orphaned.  Is there a way to find and recycle abandoned connections
> > forcibly?
> >
> > Thanks,
> > David
> >
> > On 1/8/07, David Uctaa <du...@gmail.com> wrote:
> > > Tomcat provides the removeAbandoned and removeAbandonedTimeout
> > > parameters when setting up data sources in server.xml.  But according
> > > to the documentation I've read, abandoned connections only get closed
> > > and recycled when available connections run low and new connections
> > > are requested.
> > >
> > > Is there a way for me to forcibly close/release abandoned connections
> > > on the server from a privileged application running on the same
> > > server?
> > >
> > > BTW, I'm running Tomcat 5.5 on a Windows 2003 box, running against DB2
> > > on an iSeries box (jt400 for the JDBC driver), using Tomcat's DBCP for
> > > the pooling.
> > >
> > > Thanks,
> > > David
> > >
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>
>

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


Re: How to forcibly close abandoned database connections?

Posted by Greg Foulks <gf...@gmail.com>.
David,
Any chance you could share with me your connection pool configuration? I've
been struggling with trying to setup my own connection to our DB2 using the
jt400 jar and have not been able to find any documentation for doing this
with a DB2 connection.

Thanks,
Greg


On 1/10/07, David Uctaa <du...@gmail.com> wrote:
>
> Perhaps I was unclear what it is I'm trying to do.  I have a
> connection pool set up under Tomcat 5.5, connecting to DB2 on an
> iSeries box using Tomcat's DBCP.  It is set up for 30 connections.  I
> am using Lambda Probe (a great open source Tomcat monitoring app) to
> monitor the datasources.  It is showing, let's say, that there are a
> max of 30 connections allowed, that 11 have been "established", and 9
> are "busy".  I know that these 9 are due to a connection pool leak bug
> that was corrected (but not yet deployed), so even though the
> application has gone idle and no one is using it, the connections
> remain "busy" indefinitely.  I have enabled removeAbandoned in my
> server.xml, but according to the Tomcat docs, abandoned connections
> are only recycled if there is a need for them, due to the number of
> available datasources getting low.  The number of available
> datasources are not yet low, so these orphaned connections are still
> being reported as "busy".  I'm a little bit anal with regard to
> keeping things kinda clean on the server, so I would like to have
> these abandoned connections no longer reported as "busy" once they are
> orphaned.  Is there a way to find and recycle abandoned connections
> forcibly?
>
> Thanks,
> David
>
> On 1/8/07, David Uctaa <du...@gmail.com> wrote:
> > Tomcat provides the removeAbandoned and removeAbandonedTimeout
> > parameters when setting up data sources in server.xml.  But according
> > to the documentation I've read, abandoned connections only get closed
> > and recycled when available connections run low and new connections
> > are requested.
> >
> > Is there a way for me to forcibly close/release abandoned connections
> > on the server from a privileged application running on the same
> > server?
> >
> > BTW, I'm running Tomcat 5.5 on a Windows 2003 box, running against DB2
> > on an iSeries box (jt400 for the JDBC driver), using Tomcat's DBCP for
> > the pooling.
> >
> > Thanks,
> > David
> >
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: How to forcibly close abandoned database connections?

Posted by David Uctaa <du...@gmail.com>.
Perhaps I was unclear what it is I'm trying to do.  I have a
connection pool set up under Tomcat 5.5, connecting to DB2 on an
iSeries box using Tomcat's DBCP.  It is set up for 30 connections.  I
am using Lambda Probe (a great open source Tomcat monitoring app) to
monitor the datasources.  It is showing, let's say, that there are a
max of 30 connections allowed, that 11 have been "established", and 9
are "busy".  I know that these 9 are due to a connection pool leak bug
that was corrected (but not yet deployed), so even though the
application has gone idle and no one is using it, the connections
remain "busy" indefinitely.  I have enabled removeAbandoned in my
server.xml, but according to the Tomcat docs, abandoned connections
are only recycled if there is a need for them, due to the number of
available datasources getting low.  The number of available
datasources are not yet low, so these orphaned connections are still
being reported as "busy".  I'm a little bit anal with regard to
keeping things kinda clean on the server, so I would like to have
these abandoned connections no longer reported as "busy" once they are
orphaned.  Is there a way to find and recycle abandoned connections
forcibly?

Thanks,
David

On 1/8/07, David Uctaa <du...@gmail.com> wrote:
> Tomcat provides the removeAbandoned and removeAbandonedTimeout
> parameters when setting up data sources in server.xml.  But according
> to the documentation I've read, abandoned connections only get closed
> and recycled when available connections run low and new connections
> are requested.
>
> Is there a way for me to forcibly close/release abandoned connections
> on the server from a privileged application running on the same
> server?
>
> BTW, I'm running Tomcat 5.5 on a Windows 2003 box, running against DB2
> on an iSeries box (jt400 for the JDBC driver), using Tomcat's DBCP for
> the pooling.
>
> Thanks,
> David
>

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