views:

85

answers:

1

I have a web app running on Tomcat 7, that requires a connection to multiple databases. For efficiency's sake I'd like to employ multiple connection pools using JDBC and probably DBCP. What options are available using multiple pools?

The Tomcat server has multiple, virtual hosts and web applications on each virtual host.

+1  A: 

What kind of DB layer do you plan to use - do you want to do plain JDBC, JPA, Hibernate or something else? Maybe you want to use Spring?

These choices will affect your answer.

For instance: With plain JDBC I might go with Apache Commons dbcp with a connection pool for each database. The pooled DataSource could easily be put into JNDI if that suits your application.

If you go for hibernate, then you should google the issue - there are several hits out on the net describing your problem.

Knubo
Knubo, thanks for responding. I'm currently using JDBC and have a Resource element in the app's context.xml for a single connection. What do you think?
Andrew
You could probably solve it using your current setup. I did a google for "tomcat context.xml dbcp" and it seems like someone has already done this and written about it already: http://www.crazysquirrel.com/computing/java/connection-pooling.jspx
Knubo