Can Tomcat support multiple JDBC connection pools?

1.6k Views Asked by At

I have a Spring Boot application which connects to different MySQL databases. I am planning to add connection pool support to this application. Does the Tomcat JDBC Connection Pool (default Spring boot pool) support more than one pool for each of my databases?

1

There are 1 best solutions below

0
On

Not sure how this would be different under Spring Boot, but for standard web apps you can configure this at the webapp level, by adding in web.xml any number of the following:

<resource-ref>
    <res-ref-name>jdbc/yourname</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

and in context.xml the corresponding number of the following:

<Resource name="jdbc/yourname" auth="Container" type="javax.sql.DataSource"
           maxActive="30"
           maxIdle="30"
           maxWait="2000"
           removeAbandoned="true"
           ...