2.0 gives us an opportunity to re-evaluate the default connection pool. We currently use Tomcat JDBC. That's a bit awkward when a war's deployed to Tomcat (tomcat-jdbc is always on the classpath). There's also some evidence that HikariCP performs much better.
As you may know, DBCP2 is default connection pool library from Tomcat 8.0.
(
https://tomcat.apache.org/tomcat-8.0-doc/jndi-datasource-examples-howto.html#Database_Connection_Pool_%28DBCP_2%29_Configurations
The default database connection pool implementation in Apache Tomcat relies on the libraries from the Apache Commons project. The following libraries are used:
- Commons DBCP
- Commons Pool
)
It is repackaged into org.apache.tomcat.dbcp.dbcp2.
I am wondering about why tomcat-jdbc is not default connection pool even in Tomcat. The reason can be helpful to the choice of Spring Boot 2.0. I guess that it is because of DBCP2's reliability and stability.
@wilkinsona HikariCP would be honored to become the default pool in spring-boot. If any issues turn up in your test suites, please let me know.
@wilkinsona are the any way to re-order the list programatically o by config? We are actually building and starter with Hikari dependency. However when an app include own starter and tomcat-pool obviously spring boot chose the second one. I try register programatically by using BeanDefinitionRegistryPostProcessor and BeanPostProcessor without success
@nekperu15739 we don't use the tracker for questions. Please join us on Gitter or ask on stackoverflow (but quickly there is a spring.datasource.type property for that).
thank you @snicoll for the tip, i already try defining spring.datasource.type on the starter using BeanPostProcessor over the DataSourceProperties.class without results. I believe all this become with the no avality of set the Pool order.
It looks like DataSourceBuilder was missed:
private static final String[] DATA_SOURCE_TYPE_NAMES = new String[] {
"org.apache.tomcat.jdbc.pool.DataSource",
"com.zaxxer.hikari.HikariDataSource",
"org.apache.commons.dbcp2.BasicDataSource" };
I think that magic that comes with DataSourceConfiguration using the conditionals comes with the problem of not have the ability of reorder the pool preference.
Good catch @wilkinsona, thanks!
Most helpful comment
@wilkinsona HikariCP would be honored to become the default pool in spring-boot. If any issues turn up in your test suites, please let me know.