# Spring Boot Using Hikari Connection Pool

Connection Pool

In software engineering, a connection pool is a cache of database connections maintained so that the connections can be reused when future requests to the database are required. Connection pools are used to enhance the performance of executing commands on a database. Opening and maintaining a database connection for each user, especially requests made to a dynamic database-driven website application, is costly and wastes resources. In connection pooling, after a connection is created, it is placed in the pool and it is used again so that a new connection does not have to be established. If all the connections are being used, a new connection is made and is added to the pool. Connection pooling also cuts down on the amount of time a user must wait to establish a connection to the database. Wikipedia

I’m Googling for connection pool java implementation. HikariCP is good choice for your connection pooling. how do i implementation HikariCp integrated with spring boot application.
Let’s check Step by Step :

Create Spring Project

Add dependency :
– spring-boot-starter-web
– spring-boot-starter-data-jpa
– mysql-connector-java
– lombok

Add Dependency HikariCP

Exclude default Spring Pooling

Add the Properties

application.yml

Notes :
– Create database training_hikaricp
– Edit username and password mysql. (if difference)

For Complete Java Code you cant download or clone from my Github

Run Project

How do i test ?

Test Result

  • Thread Group Setting ( 5000 request in 10 seconds)
    Thread Group Setting

    • HTTP Request
  • Graph Response Time
    Graph Response time 5K request

    • HikariCP create Connection max 50
    • Log create connection and close the connection when idle

Check the full code on my github

Happy Coding!