In Spring Boot, @Autowired a javax.sql.DataSource, and you will know which database connection pool is using in the current running application.

1. Test Default

Spring Boot example to print a javax.sql.DataSource

Read this official Spring Boot doc – Connection to a production database, to understand the algorithm for choosing a DataSource implementations – Tomcat pooling, HikariCP, Commons DBCP and Commons DBCP2.

package com.mkyong;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.sql.DataSource;

public class SpringBootConsoleApplication implements CommandLineRunner {

    DataSource dataSource;

    public static void main(String[] args) throws Exception {, args);

    public void run(String... args) throws Exception {

        System.out.println("DATASOURCE = " + dataSource);



Output, Spring Boot is using Tomcat pooling by default.

DATASOURCE = org.apache.tomcat.jdbc.pool.DataSource@7c541c15...

2. Test HikariCP

To switch to another connection pool, for example HikariCP, just exclude the default and include the HikariCP in the classpath.



        <!-- connection pools -->


DATASOURCE = HikariDataSource (HikariPool-1)
Read this example – Spring Boot JDBC + MySQL + HikariCP example


  1. HikariCP
  2. Spring Boot JDBC + MySQL + HikariCP example