I am attempting to use connection pooling using apache dbcp2.
My maxTotal connection is 5. I am closing every connection after it is used.
But still i am getting connection after 5 connection closed from connection pool.
whetehr it will ping database to get connection after 5 connections are closed ? or it will get from connection pool itself without going db.
Below is my sample code snippet. Please correct my understanding about connection pooling.
BasicDataSource bds = getBasicDataSource();
System.out.println (bds.getMaxTotal()); // Prints - 5
for (int i=0; i<10; i++) {
conn = bds.getConnection();
System.out.println("Conn "+conn); // conn object printing different values for all 10 connections
conn.close();
}