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?
Asked
Active
Viewed 1,561 times
1
-
Do you want the Tomcat or the Spring to handle connection pooling? – cihan adil seven May 12 '16 at 09:10
-
Spring. I think this will be the easiest. Basically my app is a web application written using Spring boot. – Bill Goldberg May 12 '16 at 09:16
-
Tomcat connection pools are exposed as JNDI resources. You can add as many connection pools to the Tomcat configuration as you want since each pool will need to have a unique name for it to be added to the JNDI registry. You can also use a standalone pooling library like HikariCP that you can configure using the Spring Boot configuration. – manish May 12 '16 at 09:58
-
Did this using different pooling library [C3p0](https://commons.apache.org/proper/commons-dbcp/). I don't want to handle this in server level. – Bill Goldberg May 12 '16 at 12:15
1 Answers
0
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"
...

geert3
- 7,086
- 1
- 33
- 49