how to check HikariCP connection pooling is working or not in Java?

≯℡__Kan透↙ 提交于 2019-12-01 15:18:05

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

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

See HikariCP note about MySQL:

The MySQL DataSource is known to be broken with respect to network timeout support. Use jdbcUrl configuration instead.

You need to remove the below line and Hikari will find the driver

hibernate.datasource.driver-class-name=com.mysql.jdbc.Driver

jdbcUrl This property directs HikariCP to use "DriverManager-based" configuration. We feel that DataSource-based configuration (above) is superior

Also try adding the following as suggested when using Hibernate4:

hibernate.hikari.dataSource.url=jdbc:mysql://localhost/database
hibernate.hikari.dataSource.user=bart
hibernate.hikari.dataSource.password=51mp50n
Ignacio Mosca
  1. Have you tried using the app to insert/update something in the database? If it fails then it's not working.

  2. Another way to test it is change the datasource you provided here: hibernate.hikari.dataSource.url to a non-existing database.

  3. Finally, change the <Configuration status="WARN"> to <Configuration status="DEBUG">

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!