tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: tomcat jdbc pool, creating a pool of pools, single connection memory footprint
Date Fri, 01 Jun 2012 18:37:00 GMT
Hash: SHA1


On 5/31/12 9:33 AM, S Ahmed wrote:
>> It would be easier if all databases were hosted by a single
>> instance of MySQL -- then you could use Tomcat-pool's feature of
>> being able to provide credentials when obtaining connections from
>> the pool -- and get the right database. That way, a much smaller
>> number of connections could be maintained with roughly the same
>> semantics.
> Can you expand on how I could do this?

Well, first you have to accept that the same MySQL instance (with
perhaps different databases) will be hosting all your data. If that's
not okay with you, then you can forget this suggestion (or, maybe it
just changes the suggestion slightly because you could always have N
databases and maybe 4 MySQL instances when them split across the 4...
but then you'd have to figure out which connection pool to grab before
getting a connection or you'd never get connected).

Next, you'd have to switch to tomcat-pool because commons-dbcp (the
default CP in Tomcat) does not support obtaining pooled connections
with credentials.

Next, you remove the database name from the JDBC URL (or maybe change
it to something everyone can access, like the 'test' database or
'information_schema' depending on your version of MySQL).

Then, you have your code call
DataSource.getConnection(username,password) instead of calling
DataSource.getConnection(). This gets you the right credentials for
your target database.

Finally, make sure you issue a query to set the database for the

'USE databasename;'

Then, you set your connection pool to have however many connections
you want (100?) and every client (thread) shares those connections
with every client database that runs in a particular MySQL instance.

- -chris
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools -
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message