Google Groups

Rationale behind the choice of the DataSource interface instead of Driver?

Guillaume Smet Mar 13, 2014 3:52 AM
Posted in group: HikariCP

We are considering the move to HikariCP (we are currently using the Tomcat pool) but there is something bothering us in the way we have to configure it.

Context: our core framework supports a lot of databases: PostgreSQL (which is our database of choice - I'm an ancient PostgreSQL contributor), MySQL, Oracle, SQL Server, H2... They are all configured in a generic way using a JDBC URL.

The Driver API, which is the API chosen by the connection pool we are using, allows to configure the Connection with a JDBC URL, which is comfortable as we can configure every database the same way.

HikariCP is based on the DataSource API which isn't really made to create a connection: it doesn't expose a stable interface for this and it's definitely a pain to have something generic for all the databases: the PostgreSQL DataSource implementation requires the database name, the host and the port, the SQL Server one wants a capitalized URL property whereas MySQL wants a lowercase url property...

Providing a generic way to configure the connection to a database with this API is clearly not as simple as with the Driver interface.

What is the rationale behind this choice?

Thanks for your feedback.