Tomcat可以支持多个JDBC连接池吗?

时间:2016-05-12 09:04:12

标签: spring tomcat spring-boot tomcat-jdbc

我有一个Spring Boot应用程序,它连接到不同的 MySQL 数据库。我打算为此应用程序添加连接池支持。 Tomcat JDBC连接池(默认的Spring引导池)是否为每个数据库支持多个池?

1 个答案:

答案 0 :(得分:0)

不确定在Spring Boot下这会有什么不同,但对于标准的Web应用程序,您可以在webapp级别配置此项,方法是在web.xml中添加以下任意数量的内容:

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

并在context.xml中相应的以下数字:

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