tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Laughlin <>
Subject Re: Implementing Connection Pooling
Date Fri, 02 Jul 2010 00:28:15 GMT
Thanks for responding Charles.

I'm looking at the code here -->

this code, the connection pool is not initialized until certain methods are
called.  Here's an excerpt:

"Note: this method currently has no effect once the pool has been
initialized.  The pool is initialized the first time one of the
following methods is invoked: <code>getConnection, setLogwriter,
setLoginTimeout, getLoginTimeout, getLogWriter."

So in my code I'm doing this:

 Context ctx = new InitialContext();
 org.apache.tomcat.dbcp.dbcp.BasicDataSource ds =
"java:comp/env/jdbc/DB" );

 // These must be set before the call to getConnection(), since
getConnection actually creates the pool.
 ds.setDefaultCatalog( orgID );
 ds.setUsername( orgID );
 ds.setPassword( orgID );

connection = ds.getConnection();  // then call getConnection() which calls

This should return an existing connection in an extant pool, or create a new
pool with username, password andcatalog as parameters for connection in the
new pool. Won't this have the effect I'm looking for of creating a pool per

If I'm misunderstanding could someone please walk me through were I'm going

On Thu, Jul 1, 2010 at 3:06 PM, Caldarale, Charles R <> wrote:

> > From: Andrew Laughlin []
> > Subject: Re: Implementing Connection Pooling
> >
> > The credentials for a database connection are specified per
> > database. That is, user credentials are not used to get an
> > authenticated connection to the database.  Notice OrgID is
> > the database name, username and password.
> You're not going to be able to do this with a single <Resource> element,
> since one <Resource> == one connection pool.  You'll either have to
> configure one <Resource> per OrgID (and know them all up front), or use your
> own connection pooling with commons-dbcp (or equivalent).
>  - Chuck
> MATERIAL and is thus for use only by the intended recipient. If you received
> this in error, please contact the sender and delete the e-mail and its
> attachments from all computers.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message