New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for HikariCP DataSource #418
Comments
Thanks for the information. We currently only use It looks like HikariCP required Java 1.7. This might be a showstopper for us since we are currently trying to remain Java 1.6 compatible. Having said that, it might be nice if this were an auto-configuration option so that if people choose to use it, it just works. If you are interested in submitting a pull-request take a look at the I'm afraid, even with a pull-request, this is something that won't make the 1.0.0 since we now at the RC stage and we are trying to stabilize things. |
The next release of HikariCP has been back ported to Java6, it will be published later the week. I'll take look at the DataSourceAutoConfiguration class, and put together a pull request. |
Cheers. BTW I previously read your Down The Rabbit Hole article and I have been meaning to take a closer look at the project. |
I've forked spring-boot and started looking at DataSourceAutoConfiguration, and I have a question. It appears that String driverClassName = getDriverClassName(context.getEnvironment(),
getDataSourceClassLoader(context));
if (driverClassName == null) {
return ConditionOutcome.noMatch("no database driver");
} But one of the points of a JDBC DataSource was to get away from requiring explicitly loading a driver class. Additionally, it appears that String url = getUrl(context.getEnvironment(), context.getClassLoader());
if (url == null) {
return ConditionOutcome.noMatch("no database URL");
} Again, the JDBC DataSource was a move away from URL-based connection configuration. HikariCP uses neither. Quoting variously from Oracle's DataSource tutorial:
In the section Advantages of DataSource Objects:
Any advice on how to approach changes to |
Sorry I don't follow. Can you paste a link to some HikariCP code that would elucidate? An application doesn't need to know JDBC connection details if it gets a |
I was referring not application-level code but instead submitting, as Phil suggested, a pull request for an auto-configuration class to integrate HikariCP into spring-boot. The suggestion was to look at ``DataSourceAutoConfiguration`. The following are two examples of configuring a HikariCP DataSource: HikariDataSource ds = new HikariDataSource();
ds.setMaximumPoolSize(100);
ds.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
ds.addDataSourceProperty("url", "jdbc:mysql://localhost/database");
ds.addDataSourceProperty("user", "bart");
ds.addDataSourceProperty("password", "51mp50n"); or using a configuration object (HikariConfig) and properties file: HikariConfig config = new HikariConfig("hikari.properties");
HikariDataSource ds = new HikariDataSource(config); where dataSourceClassName=org.postgresql.ds.PGSimpleDataSource
dataSource.user=test
dataSource.password=test
dataSource.databaseName=mydb
dataSource.serverName=localhost Notice in both cases, there is no reference to a Driver class and there is no JDBC connection URL (DataSources don't need them). So, turning back to Even if I override I'm just looking for some guidance here as to what and where to make precise changes so as to accomplish the task of integrating HikariCP along with minimizing the change to existing code. |
@philwebb We have just released HikariCP 1.3.2 with Java 6 support (formerly only Java 7). I know it is "late" in the release cycle, but I would recommend reading our competitive pool analysis, especially if you are going into production with Tomcat-jdbc. Tomcat has issues that cannot be mitigated though configuration, but it also has issues that can be mitigated and you might be wise to do so. |
Thanks for the support of HikariCP. Thought you'd might be interested in this real-world deployment result vs BoneCP. |
We still prefer Tomcat if it is available (that can change if the community asks loudly enough). Hikari is supported via the same spring.datasource.* properties as Tomcat (and DBCP), with some modifications: * The validation and timeout settings are not as fine-grained in Hikari, so many of them will simply be ignored. The most common options (url, username, password, driverClassName) all work as expected. * The Hikari team recommends using a vendor-specific DataSource via spring.datasource.dataSourceClassName and supplying it with Properties (spring.datasource.hikari.*). Hikari prefers the JDBC4 isValid() API (encapsulates vendor- specific queries) which is probably a good thing, but we haven't provided any explicit support or testing for that yet. Fixes spring-projectsgh-418
First, thanks for the excellent project. I noticed you are using commons-dbcp. Even Apache Tomcat has officially abandoned commons-dbcp in favor of their own pool. While there are many pool choices out there, I invite you to check-out our pool, HikariCP. Not just for performance, but correctness. HikariCP is in wide use (as you can tell by our "Stars"), and active development, with over 2500 downloads from maven central repository in just the past month.
The text was updated successfully, but these errors were encountered: