简体   繁体   English

同一数据库上有多个连接池

[英]Multiple connection pools on the same database

In my application, I need to configure 2 databases during start up. 在我的应用程序中,我需要在启动期间配置2个数据库。 They are created as Tomcat JDBC pools - org.apache.tomcat.jdbc.pool with seperate pool properties. 它们被创建为Tomcat JDBC池-具有单独的池属性的org.apache.tomcat.jdbc.pool。 If I configure such that both the database URLs, user name and password are same ie, both point to the same database server, then how will be the connection pool created? 如果我将数据库URL,用户名和密码都配置为相同,即都指向同一个数据库服务器,那么如何创建连接池? Will it create 2 pools with different properties or only one? 它会创建两个具有不同属性的池还是仅创建一个? If its only one, which pool properties will be set to the pool - the one which is first created or the next? 如果只有一个,则将哪个池属性设置为该池-第一个还是下一个? Also please suggest if there is any tool which can be used to see the connections to a database and the pools created on it? 还请建议是否有任何工具可用于查看与数据库的连接以及在数据库上创建的池?

My guess is that they would create two separate pools. 我的猜测是,他们将创建两个单独的池。 You can check the SQL server for the "active connections" which the pool should keep a few alive. 您可以检查SQL Server的“活动连接”,该连接应使池保持活动状态。

My suggestion though, is to use HikariCP as your connection pool. 但是我的建议是使用HikariCP作为您的连接池。 I've found it to be the most robust (survives even if the SQL server goes down) and the fastest (lightest, and smallest lib). 我发现它是最健壮的(即使SQL Server崩溃也可以幸存)和最快的(最轻,最小的lib)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM