Thanks, Chris. To answer your suggestion first, differing username/password didn't come into play, because I found that the PostgreSQL JDBC driver does not implement the setCatalog method to change databases on the fly in the first place. (Apparently this is optional for JDBC driver implementers.)

So, I went ahead and set a single JNDI dataSource for the one "central" database we use to coordinate all other databases, then created a HashMap to store DataSource instances by database name. It's all working well so far.

Ric

On 10/28/2014 4:13 AM, Christopher Schultz wrote:
Alternatively, I can manage my own cache of connection pools (i.e.,
org.apache.tomcat.jdbc.pool.DataSource instances), keyed off of
database name in a HashMap, for example, and storing that cache in
an object that is persisted across web service calls (using JAX-RS
Features). Do you see any problem with retaining
org.apache.tomcat.jdbc.pool.DataSource instances in memory and
re-using them for extended periods of time?

None!

The JNDI implementation in Tomcat is essentially a hash map, so you
would be doing something very similar to what Tomcat already provides.

You could even inject your own DataSource objects into Tomcat's JNDI
map and then your application would be a little bit more "standard".

- -chris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to