tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "rahul" <rahul.jo...@amsoft.net>
Subject HOW DOES TOMCAT JNDI CONNECTION POOLING WORKS
Date Fri, 23 Sep 2005 10:32:59 GMT
Hi all,
My questing is derived from the sample code given
at :
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-how
to.html#Database%20Connection%20Pool%20(DBCP)%20Configurations


If you can see the subsection 4(i.e. testcode) of section "MySQL DBCP
Example",
to get a connection following code is used:
***************************************************
Context ctx = new InitialContext();
if(ctx == null )
throw new Exception("Boom - No Context");
DataSource ds =
(DataSource)ctx.lookup(
"java:comp/env/jdbc/TestDB");
if (ds != null) {
Connection conn = ds.getConnection();
***************************************************

I guess by doing this a connection is obtained FROM THE POOL providing that
a connection is free in the pool.

I have got two questions regarding this-

Q 1. Does tomcat really looks into the pool to get me a connection? or it
just creates
a newone? I am asking this question because I am seeing(using eclipse
debugger)
two connection opened at the same time even after defining
maxActive="1" maxIdle="1" in my application'c context


Q 2. once your database operation is done you free the connection using
****************
conn.close();
****************
by doing this are we pushing the connection back into pool? if not then how
is
pool maintained?


Any help is appreciated

--RahulJoshi



---------------------------------------------------------------------
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