You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Dan Randall <DR...@valley-media.com> on 2001/05/04 20:32:20 UTC

Loosing Connections in a pool

Hi,

My tomcat application runs in a production environment for about 24 hours before it fails and must be restarted.  During that time JDBC connections to Oracle become ignored and eventually disappear.  A fair guess is that I am loosing memory, threads and  resources in general until there is nothing left and only a restart cures the matter.

Unfortunately, tomcat, rather than apache is serving much of the pages and graphics.  That may be a contributing factor?

I am using:

Solaris 8
Oracle 8.1.7
tomcat 3.2.1
apache 1.3.19
and Java 1.3

Does anyone have an idea of what sort of problems I might be having?  Any known resource leaks or threading issues?

Thanks!!

Dan


RE: Loosing Connections in a pool

Posted by Filip Hanik <ma...@filip.net>.
Rainer is right,
your code should look like this

Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try
{
  con = getConnection();
  stmt = con.createStatement();
  //execute your query and parse the result set
}finally
{
  //clean up resources - always!
  if ( rs   != null ) try{ rs.close()  }catch (Exception ignore){}
  if ( stmt != null ) try{ stmt.close()}catch (Exception ignore){}
  if ( con  != null ) try{ con.close() }catch (Exception ignore){}
  //assuming con.close returns the connection to the pool.
}

if your code, doesn't have a finally, now is probably a good time to start
using it to ensure that your code cleans up after itself.

Filip

~
Namaste - I bow to the divine in you
~
Filip Hanik
Software Architect
filip@filip.net
www.filip.net

> -----Original Message-----
> From: Rainer Mager [mailto:rmager@vgkk.com]
> Sent: Sunday, May 06, 2001 4:16 PM
> To: tomcat-user@jakarta.apache.org
> Subject: RE: Loosing Connections in a pool
>
>
> Have you tried running your application for a long time without
> Tomcat? That
> is, are you sure the problem is Tomcat related. Specifically, we found the
> the Oracle JDBC drivers have a memory leak such that if you don't
> explicitly
> close the Statements the connection will keep a reference to them and
> allocate more and more memory.
>
>
> --Rainer
>
>
> > -----Original Message-----
> > From: Dan Randall [mailto:DRR1@valley-media.com]
> > Sent: Saturday, May 05, 2001 3:32 AM
> > To: tomcat-user@jakarta.apache.org
> > Subject: Loosing Connections in a pool
> >
> >
> > Hi,
> >
> > My tomcat application runs in a production environment for about
> > 24 hours before it fails and must be restarted.  During that time
> > JDBC connections to Oracle become ignored and eventually
> > disappear.  A fair guess is that I am loosing memory, threads and
> >  resources in general until there is nothing left and only a
> > restart cures the matter.
> >
> > Unfortunately, tomcat, rather than apache is serving much of the
> > pages and graphics.  That may be a contributing factor?
> >
> > I am using:
> >
> > Solaris 8
> > Oracle 8.1.7
> > tomcat 3.2.1
> > apache 1.3.19
> > and Java 1.3
> >
> > Does anyone have an idea of what sort of problems I might be
> > having?  Any known resource leaks or threading issues?
> >
> > Thanks!!
> >
> > Dan
> >
>
>


RE: Loosing Connections in a pool

Posted by Rainer Mager <rm...@vgkk.com>.
Have you tried running your application for a long time without Tomcat? That
is, are you sure the problem is Tomcat related. Specifically, we found the
the Oracle JDBC drivers have a memory leak such that if you don't explicitly
close the Statements the connection will keep a reference to them and
allocate more and more memory.


--Rainer


> -----Original Message-----
> From: Dan Randall [mailto:DRR1@valley-media.com]
> Sent: Saturday, May 05, 2001 3:32 AM
> To: tomcat-user@jakarta.apache.org
> Subject: Loosing Connections in a pool
>
>
> Hi,
>
> My tomcat application runs in a production environment for about
> 24 hours before it fails and must be restarted.  During that time
> JDBC connections to Oracle become ignored and eventually
> disappear.  A fair guess is that I am loosing memory, threads and
>  resources in general until there is nothing left and only a
> restart cures the matter.
>
> Unfortunately, tomcat, rather than apache is serving much of the
> pages and graphics.  That may be a contributing factor?
>
> I am using:
>
> Solaris 8
> Oracle 8.1.7
> tomcat 3.2.1
> apache 1.3.19
> and Java 1.3
>
> Does anyone have an idea of what sort of problems I might be
> having?  Any known resource leaks or threading issues?
>
> Thanks!!
>
> Dan
>