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


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



I have written following properties in my configuration files I am using Log4j
in my application When I am running a project.


Log4j



I am getting following message.does that mean connection pooling is configured in my project? if not then how it will be?



INFO: internal.ConnectionProviderInitiator - HHH000130: Instantiating explicit connection provider: com.zaxxer.hikari.hibernate.HikariConnectionProvider



I have referred following link also



link here



Datasource settings


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 Settings


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





May be this will useful:stackoverflow.com/questions/5134515/…
– soorapadman
Jul 2 at 13:14





@soorapadman INFO: internal.ConnectionProviderInitiator - HHH000130: Instantiating explicit connection provider: com.zaxxer.hikari.hibernate.HikariConnectionProvider does this means connection pooling is established.?
– Tejal
Jul 2 at 13:15





Please add poolname and check weather its initiating or not . Obviously initialize connection pool one time only.
– soorapadman
Jul 2 at 13:20





@soorapadman yes right after loading I am getting INFO: internal.ConnectionProviderInitiator - HHH000130.... into console
– Tejal
Jul 2 at 13:23





Look like your configuration fine for me .
– soorapadman
Jul 2 at 13:28




2 Answers
2



Have you tried using the app to insert/update something in the database? If it fails then it's not working.



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


hibernate.hikari.dataSource.url



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


<Configuration status="WARN">


<Configuration status="DEBUG">





1. yes I tried inserting data into db its working fine but how I will know connection pooling is established? 2) .can you elaborate more 3).yes I tried this also
– Tejal
Jul 2 at 13:08






Try changing hibernate.hikari.dataSource.url from jdbc:mysql://localhost:3306/mydb to jdbc:mysql://idontexisthost:3306/mydb to check if everything goes down. Also, do you see stuff logging when you insert something into the database?
– Ignacio Mosca
Jul 2 at 14:19



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






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

How to set up datasource with Spring for HikariCP?

PHP contact form sending but not receiving emails