问题描述
我在使用Log4j
的配置文件中写入了以下属性在我的应用程序中运行项目时.
I have written following properties in my configuration files I am using Log4j
in my application When I am running a project.
我收到以下消息.这是否意味着在我的项目中配置了连接池?如果没有的话,情况会怎样?
I am getting following message.does that mean connection pooling is configured in my project? if not then how it will be?
信息:internal.ConnectionProviderInitiator-HHH000130:实例化显式连接提供程序:com.zaxxer.hikari.hibernate.HikariConnectionProvider
我也引用了以下链接
hibernate.datasource.driver-class-name=com.mysql.jdbc.Driver
hibernate.datasource.url=jdbc:mysql://localhost:3306/mydb
hibernate.datasource.username=root
hibernate.datasource.password=root
HikariCP设置
hibernate.hikari.dataSource.url=jdbc:mysql://localhost:3306/mydb
hibernate.hikari.idleTimeout=10
hibernate.hikari.maximumPoolSize=30
hibernate.hikari.minimumIdle=15
hibernate.connection.provider_class=com.zaxxer.hikari.hibernate.HikariConnectionProvider
hibernate.hikari.dataSourceClassName=com.mysql.jdbc.jdbc2.optional.MysqlDataSource
推荐答案
首先,由于最大值< minimumIdle.这些值最多应设置为相同的值.
First, configuration is no consistent since maximum < minimumIdle. Those should be set at most to the same value.
hibernate.hikari.maximumPoolSize=10
hibernate.hikari.minimumIdle=10
如果池正在工作,您应该会看到10个建立到端口3306的连接.
If the pools is working you should see 10 ESTABLISHED connections to port 3306.
netstat -ant | grep 3306
tcp 0 0 127.0.0.1:41722 127.0.0.1:3306 ESTABLISHED
tcp 0 0 127.0.0.1:41730 127.0.0.1:3306 ESTABLISHED
tcp 0 0 127.0.0.1:41728 127.0.0.1:3306 ESTABLISHED
tcp 0 0 127.0.0.1:41726 127.0.0.1:3306 ESTABLISHED
tcp 0 0 127.0.0.1:41716 127.0.0.1:3306 ESTABLISHED
tcp 0 0 127.0.0.1:41732 127.0.0.1:3306 ESTABLISHED
tcp 0 0 127.0.0.1:41720 127.0.0.1:3306 ESTABLISHED
tcp 0 0 127.0.0.1:41736 127.0.0.1:3306 ESTABLISHED
tcp 0 0 127.0.0.1:41718 127.0.0.1:3306 ESTABLISHED
tcp 0 0 127.0.0.1:41724 127.0.0.1:3306 ESTABLISHED
这篇关于如何在Java中检查HikariCP连接池是否正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!