tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ric Bernat" <>
Subject RE: Tomcat 7 JDBC Connection Pool - question about usage from Java code
Date Sun, 26 Oct 2014 01:06:00 GMT
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.


-----Original Message-----
From: Konstantin Kolinko [] 
Sent: Saturday, October 25, 2014 3:25 PM
To: Tomcat Users List
Subject: Re: Tomcat 7 JDBC Connection Pool - question about usage from Java code

2014-10-26 1:49 GMT+04:00 Ric Bernat <>:
>> There is no such method to be called like on the above line.
>> "DataSource(PoolConfiguration)" is a constructor. To call a constructor you need
the keyword "new".
> My bad: I copied some code around and dropped the "new." You are quite right: I am calling
the constructor.
>> No. A constructor creates a new object.
> Of course, I realize a constructor creates a new object. However, I had assumed that
connections opened from two separate DataSource instances would still coexist in the same
Tomcat connection pool.
> To confirm: you are saying that one DataSource instance == one connection pool, period.

With that code, yes.

> (...)
> In the context of a JAX-RS application, this means I must persist my DataSource instances
in memory across web service calls (which is fine, I can do that), and reuse them.


> Otherwise I simply am not getting any connection pooling at all. Right?

You get pooling for the duration of that single web service call. If open connection several
times during that single call, all those connections will come from the same pool.


Best regards,
Konstantin Kolinko

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

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

View raw message