tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Tomcat 7 JDBC Connection Pool - question about usage from Java code
Date Sun, 26 Oct 2014 13:10:25 GMT
Hash: SHA256


On 10/25/14 9:06 PM, Ric Bernat wrote:
> Thanks. That makes sense. Pooling for the duration of that single
> web service call is not our main goal. However, JAX-RS allows me
> to persist objects in memory across web service calls, so I can
> keep a collection of DataSource instances (e.g., by database name,
> in a ConcurrentHashMap). No problem keeping DataSource instances in
> memory for an extended period of time, is there?
> btw, I have worked with Microsoft tools in the past, including SQL 
> Server ADO.NET connection pooling. There, you get one connection
> pool per connection string, regardless of what object instance you
> use to instantiate your connection objects. That is doubtlessly why
> I came to Tomcat connection pooling with a 
> connection-URL-equals-connection-pool mindset.
> On a tangent, I am very eager to monitor Tomcat connection pooling
> so that I can see what is going on with the connection pools. To
> that end, I have configured both the JMXProxyServlet (via the
> "manage" webapp), and PSI Probe. And I have set 
> poolProperties.setJmxEnabled(true). However, neither of these 
> monitoring tools let me see any information about Tomcat
> connection pool state. Perhaps these tools required that I JNDI to
> configure my database connections, and cannot monitor connection
> pools created via Java code?
> Unless I am using those two monitoring tools incorrectly (quite 
> possible), and they really do offer a view of connection pool
> state, it seems that my only choice is to configure JMX monitoring,
> which seems non-trivial. (I am assuming that JMX will give me a
> view of connection pool state.)
> Or perhaps I should go the JNDI route (guessing that my two
> current monitoring apps can show connection pooling information
> for JNDI-created connection pools). However, since we create
> databases at runtime, I'm not sure that I would be able to create
> JNDI declarations for just-created databases on the fly.

I haven't used non-JNDI connection pools, so I'm not absolutely sure
about this.

- From the tomcat-pool documentation[1]:
The connection pool object exposes an MBean that can be registered. In
order for the connection pool object to create the MBean, the flag
jmxEnabled has to be set to true. This doesn't imply that the pool
will be registered with an MBean server, merely that the MBean is
created. In a container like Tomcat, Tomcat itself registers the
DataSource with the MBean server, the
org.apache.tomcat.jdbc.pool.DataSource object will then register the
actual connection pool MBean. If you're running outside of a
container, you can register the DataSource yourself under any object
name you specify, and it propagates the registration to the underlying
pool. To do this you would call
Prior to this call, ensure that the pool has been created by calling

So, the JMX bean is being created, but it's not registered with the
JMX server so you can't see the bean remotely. You'll have to register
it yourself as described above.

That one-line call isn't entirely straightforward, so let me refer you
to a presentation on monitoring Tomcat via JMX which shows you how to
register your own beans. (In your case, the bean exists already, so
you'll just be registering the bean from tomcat-pool):

Hope that helps,
- -chris

Version: GnuPG v1
Comment: GPGTools -


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

View raw message