You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by William Wragg <wi...@datapro.co.uk> on 2002/09/05 15:42:00 UTC

JDBC connection persistence

Hi,

I have developed a webapp which connects to a database and retrieves data 
for display via JDBC. There are only a few pages and each page opens and 
then closes the connection to the database. The problem is that our 
database has only a set number of licensed concurrent connections, and 
although the connections have been closed they hang around, using up the 
licensed connections. At what appear to be random times the old closed 
connections get cleared up which frees up some more licensed connections.

I have tried writing the database retrieval in both jsp tags (sql taglibs) 
and in pure java and get the same problem. The connections are definitely 
closed as I have checked if the connection is null after I have closed the 
connection. Also the database confirms that there are no external 
connections to it.

I am running Tomcat 4.0.4, java sdk 1.3_02, on Caldera OpenLinux 3.1.1 
(kernal 2.4.13) and SCO OpenServer 5.0.5a

Have I missed something about the setup of JDBC connections. Do they 
persist by default, until something triggers a cleanup?

Any help would be greatly appreciated.

Regards,

Wm.

RE: JDBC connection persistence

Posted by Andrew Conrad <an...@attbi.com>.
No, because DBCP doesn't actually close connections, it returns them to
the connection pool for reuse.


- Andrew

> -----Original Message-----
> From: William Wragg [mailto:william@datapro.co.uk] 
> Sent: Friday, September 06, 2002 12:33 PM
> To: Tomcat Users List
> Subject: RE: JDBC connection persistence
> 
> 
> Hi,
> 
> Thanks for the input. I have tried making sure all resources 
> are closed by 
> closing them myself with xxx.close() but I still get 
> connections hanging 
> around. I will look into the DBCP, but if manually closing all the 
> resources does not solve the problem, will DBCP?
> 
> Regards,
> 
> Wm.
> 
> At 16:08 05/09/2002, you wrote:
> 
> >Your best bet is to use a database connection pool.  Look into DBCP. 
> >You can set the max number of connections and all your apps 
> can share 
> >these connections.
> >
> >
> >As for your issues, it sounds like the JDBC driver is not closing
> >everything when you call connection.close().   There has been some
> >discussion on how this is suppose to operate on this list, but in 
> >general everyone reccomends that you close your recordsets and your 
> >statements individually, so your resources are cleaned up 
> immediately, 
> >not by garbage collection.
> >
> >- Andrew
> >
> > > -----Original Message-----
> > > From: William Wragg [mailto:william@datapro.co.uk]
> > > Sent: Thursday, September 05, 2002 9:42 AM
> > > To: tomcat-user@jakarta.apache.org
> > > Subject: JDBC connection persistence
> > >
> > >
> > > Hi,
> > >
> > > I have developed a webapp which connects to a database 
> and retrieves 
> > > data for display via JDBC. There are only a few pages and each
> > > page opens and
> > > then closes the connection to the database. The problem 
> is that our
> > > database has only a set number of licensed concurrent
> > > connections, and
> > > although the connections have been closed they hang around,
> > > using up the
> > > licensed connections. At what appear to be random times the
> > > old closed
> > > connections get cleared up which frees up some more licensed
> > > connections.
> > >
> > > I have tried writing the database retrieval in both jsp tags (sql 
> > > taglibs) and in pure java and get the same problem. The 
> connections
> > > are definitely
> > > closed as I have checked if the connection is null after I
> > > have closed the
> > > connection. Also the database confirms that there are no external
> > > connections to it.
> > >
> > > I am running Tomcat 4.0.4, java sdk 1.3_02, on Caldera OpenLinux 
> > > 3.1.1 (kernal 2.4.13) and SCO OpenServer 5.0.5a
> > >
> > > Have I missed something about the setup of JDBC 
> connections. Do they 
> > > persist by default, until something triggers a cleanup?
> > >
> > > Any help would be greatly appreciated.
> > >
> > > Regards,
> > >
> > > Wm.
> > >
> >
> >
> >--
> >To unsubscribe, e-mail:   
> <mailto:tomcat-user-> unsubscribe@jakarta.apache.org>
> >For 
> additional commands, 
> e-mail: 
> ><ma...@jakarta.apache.org>
> >
> >
> >---
> >Incoming mail is certified Virus Free.
> >Checked by AVG anti-virus system (http://www.grisoft.com).
> >Version: 6.0.384 / Virus Database: 216 - Release Date: 21/08/2002
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: JDBC connection persistence

Posted by William Wragg <wi...@datapro.co.uk>.
Hi,

Thanks for the input. I have tried making sure all resources are closed by 
closing them myself with xxx.close() but I still get connections hanging 
around. I will look into the DBCP, but if manually closing all the 
resources does not solve the problem, will DBCP?

Regards,

Wm.

At 16:08 05/09/2002, you wrote:

>Your best bet is to use a database connection pool.  Look into DBCP.
>You can set the max number of connections and all your apps can share
>these connections.
>
>
>As for your issues, it sounds like the JDBC driver is not closing
>everything when you call connection.close().   There has been some
>discussion on how this is suppose to operate on this list, but in
>general everyone reccomends that you close your recordsets and your
>statements individually, so your resources are cleaned up immediately,
>not by garbage collection.
>
>- Andrew
>
> > -----Original Message-----
> > From: William Wragg [mailto:william@datapro.co.uk]
> > Sent: Thursday, September 05, 2002 9:42 AM
> > To: tomcat-user@jakarta.apache.org
> > Subject: JDBC connection persistence
> >
> >
> > Hi,
> >
> > I have developed a webapp which connects to a database and
> > retrieves data
> > for display via JDBC. There are only a few pages and each
> > page opens and
> > then closes the connection to the database. The problem is that our
> > database has only a set number of licensed concurrent
> > connections, and
> > although the connections have been closed they hang around,
> > using up the
> > licensed connections. At what appear to be random times the
> > old closed
> > connections get cleared up which frees up some more licensed
> > connections.
> >
> > I have tried writing the database retrieval in both jsp tags
> > (sql taglibs)
> > and in pure java and get the same problem. The connections
> > are definitely
> > closed as I have checked if the connection is null after I
> > have closed the
> > connection. Also the database confirms that there are no external
> > connections to it.
> >
> > I am running Tomcat 4.0.4, java sdk 1.3_02, on Caldera
> > OpenLinux 3.1.1
> > (kernal 2.4.13) and SCO OpenServer 5.0.5a
> >
> > Have I missed something about the setup of JDBC connections. Do they
> > persist by default, until something triggers a cleanup?
> >
> > Any help would be greatly appreciated.
> >
> > Regards,
> >
> > Wm.
> >
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.384 / Virus Database: 216 - Release Date: 21/08/2002

RE: JDBC connection persistence

Posted by Andrew Conrad <an...@attbi.com>.
Your best bet is to use a database connection pool.  Look into DBCP.
You can set the max number of connections and all your apps can share
these connections.


As for your issues, it sounds like the JDBC driver is not closing
everything when you call connection.close().   There has been some
discussion on how this is suppose to operate on this list, but in
general everyone reccomends that you close your recordsets and your
statements individually, so your resources are cleaned up immediately,
not by garbage collection.

- Andrew

> -----Original Message-----
> From: William Wragg [mailto:william@datapro.co.uk] 
> Sent: Thursday, September 05, 2002 9:42 AM
> To: tomcat-user@jakarta.apache.org
> Subject: JDBC connection persistence
> 
> 
> Hi,
> 
> I have developed a webapp which connects to a database and 
> retrieves data 
> for display via JDBC. There are only a few pages and each 
> page opens and 
> then closes the connection to the database. The problem is that our 
> database has only a set number of licensed concurrent 
> connections, and 
> although the connections have been closed they hang around, 
> using up the 
> licensed connections. At what appear to be random times the 
> old closed 
> connections get cleared up which frees up some more licensed 
> connections.
> 
> I have tried writing the database retrieval in both jsp tags 
> (sql taglibs) 
> and in pure java and get the same problem. The connections 
> are definitely 
> closed as I have checked if the connection is null after I 
> have closed the 
> connection. Also the database confirms that there are no external 
> connections to it.
> 
> I am running Tomcat 4.0.4, java sdk 1.3_02, on Caldera 
> OpenLinux 3.1.1 
> (kernal 2.4.13) and SCO OpenServer 5.0.5a
> 
> Have I missed something about the setup of JDBC connections. Do they 
> persist by default, until something triggers a cleanup?
> 
> Any help would be greatly appreciated.
> 
> Regards,
> 
> Wm.
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>