tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Wichman <h...@trimm.nl>
Subject RE: mysql connection pool
Date Mon, 28 Jul 2003 14:50:23 GMT
Hmm, ok, but why then is the getNumActive always 0 even if I do not 
explicitly close the connection.

Even worse:
If I specify I have max 2 connections (as an example) in the pool then I 
can repeat this :
Context ctx = new InitialContext()
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/TestDB");
ds.getConnection();

for ever and ever without emptying the pool, however if I do
Context ctx = new InitialContext()
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/TestDB");
ds.getConnection();
ds.getConnection();
ds.getConnection();

I get an exception. Now this latter behavior is what I expect. The former, 
if what you say is true, is
not what I expect, do you have any ideas?

greetz
Hans





At 09:44 AM 7/28/2003 -0500, Mike Curwen wrote:
>By 'new pool instance' do you mean that:
>
>Context ctx = new InitialContext();
>DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/TestDB");
>System.out.println("ds instance : " + ds);
>
>The result of System.out.println is always a different value ?  In this
>case, it's not a new instance of the pool, it's the new variable that
>refers to a single instance of the pool.   Just double checking.
>
>
>
>
> > -----Original Message-----
> > From: Hans Wichman [mailto:hans@trimm.nl]
> > Sent: Monday, July 28, 2003 9:27 AM
> > To: Tomcat Users List; Tomcat Users List
> > Subject: RE: mysql connection pool
> >
> >
> > ok great, but why does the lookup for a datasource always
> > return a new pool
> > instance ?
> > I am running tomcat 4.0.1, maybe that is the problem?
> >
> > hope you can help
> > Hans
> >
> > At 04:13 PM 7/28/2003 +0200, Ralph Einfeldt wrote:
> > >That doesn't happen under java.
> > >
> > >You have to explicitly free/close all resources
> > >that are more valuable than memory (file handles,
> > >db connections, ...)
> > >
> > >The finalizer is called by the garbage collector,
> > >which in turn can run any time or not even at all
> > >(if you don't consume enough memory).
> > >
> > > >From the JavaDoc:
> > >
> > >finalize():
> > >Called by the garbage collector on an object when
> > >garbage collection determines that there are no
> > >more references to the object.
> > >
> > > > -----Original Message-----
> > > > From: Hans Wichman [mailto:hans@trimm.nl]
> > > > Sent: Monday, July 28, 2003 4:03 PM
> > > > To: tomcat-user@jakarta.apache.org
> > > > Subject: mysql connection pool
> > > >
> > > >
> > > > Hi,
> > > > does anyone know why I have to close the connection
> > retrieved from a
> > > > mysql  database connection pool ? Isn't the connection
> > returned to
> > > > the pool automatically when the object goes out of scope?
> > > >
> > > > And why is the datasource.getNumActive() value always 0
> > even though
> > > > I have multiple connections open ?
> > > >
> > >
> > >---------------------------------------------------------------------
> > >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> >
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


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


Mime
View raw message