The answer is "yes".

Tomcat implements the JNDI DataSource interface, as well as the JNDI 
InitialContext interface required to use this.  The JNDI Resources HOW-TO 
(http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-resources-howto.html) 
describes generally how to configure initialization values in config files, 
while the JNDI DataSource HOW-TO 
(http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html)
 gives some specifics for using connection pooling with MySQL and Oracle.

In your code, using connection pooling is quite simple.  To get a connection, 
you use the DataSource:

Context initContext = new InitialContext();
Context envContext  = (Context)initContext.lookup("java:/comp/env"); // all 
configured resources are here
DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle"); // resource 
from server.xml and web.xml
Connection conn = ds.getConnection();

To avoid leaks, you MUST explicitly close each ResultSet, Statement, and 
Connection you open.

Note that use of the connection pooling is in no way tied to other J2EE 
technologies, specifically EJBs.  Your service code runs in the context of a 
webapp and thus has access to pooling. 

Scott Nichol

Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.

----- Original Message ----- 
From: "Martin Vossler" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, December 13, 2004 10:01 AM
Subject: tomcat connection pooling


> Does anyone know if its possible for an Apache Soap service to leverage 
> Tomcats database connection pooling features?  Any point in the right 
> direction for where to find such information is greatly appreciated.
>

Reply via email to