Hikari Connection Pooling Example

By | August 5, 2018

In Previous few Posts We had learnt about following Database Connection Pools:
MysqlDataSource example
DBCP Connection Pooling Example
C3P0 JDBC connection pool Example
BoneCP connection pool example

In this post we will learn about Hikari Connection Pooling with JDBC.

Note:You have to add few dependencies binaries in your project class path those dependencies you can see in the blow project lib folder 

Project structure in eclipse:

Create database.properties file in src folder as shown in the above project structure and make entry of below properties.

SQL Query to create employee_table in MySQL (jdbcpooldb schema) 

Once you execute above db script your database schema(jdbcpooldb) will be created and employee_table will be created with three rows as below. 

Utility class which is responsible to get JDBC connection object using  Hikari DataSource connection pool With MYSQL Database.

This Client class makes use of DBUtil.getDataSource() method to take connection from  Hikari connection pool With MYSQL Database. 

After running ClientTest.java program you will look below  output on eclipse console: 

Above eclipse console output shows we are able to read rows from MySQL database that means we are successfully taken database connection using Hikari connection pool

That’s all about this topic Hikari Connection Pooling Example.

If you have any feedback or suggestion please feel free to drop in blow comment box.

Leave a Reply

Your email address will not be published. Required fields are marked *