Dbcp connection pooling create more conncetion as expected

695 views Asked by At

I am new in DBCP. I am using DBCP connection pool with Spring and hibernate ,Database is MYSQL. I am unable to find how many connections are created in connection pool. Every time it's giving different processlist count.

I am using configuration is:

 <code>
 dbcp.maxActive =11
 dbcp.maxIdle =70
 dbcp.validationQuery=SELECT 1
 dbcp.minIdle =6
 dbcp.timeBetweenEvictionRunsMillis=34000
 dbcp.minEvictableIdleTimeMillis = 55000
 dbcp.testOnBorrow =true
</code>

Please help me out if any one having idea. Thanks

2

There are 2 answers

0
Bhargav Modi On BEST ANSWER

The default dbcp connection pool is 8 connections, so if you want to run 9 simultaneous queries one of them will be blocked. From the javadocs, you should be able to read this from the getNumIdle() and getNumActive() methods, if you can get an instance of the BasicDataSource or connect to the database and run exec sp_who2 which will show you what is connected, and active, and whether any queries are being blocked. One suggestion is their if you are aware about it DBCP,it has more issues and I would suggest you to use HikariCP, it has got the most of it (ideal for performance related tasks) here the link which will give you a useful for demo and lastly use Spring's SimpleJdbcTemplate which are more involved in simplicity.

1
brettw On

Disclaimer: I am a HikariCP developer. I would also of course recommend HikariCP, but basically DBCP is one of the poorest pools out there. If not HikariCP, try Tomcat DBCP or Vibur. If you enable DEBUG logging for HikariCP, it is not "noisy" at all, and you will get pool statistics logged every 30 seconds.