HikariCP: IllegalArgumentException: dataSource or dataSourceClassNa or jdbcUrl is required

I’m using the SchemaExport utility with needsJdbc=false to generate a SQL Schema. The hibernate-hikaricp JAR is on the classpath because im generating the schema during a Maven build, using the following Java code:

final SchemaExport export = new SchemaExport();
export.doExecution(Action.CREATE, false, metadata, reg, new TargetDescriptorImpl(sql));

With 5.3.5.Final, the Hikari connection pool is initialized even though needsJdbc is false. This results in the following exception:

Caused by: org.hibernate.HibernateException: java.lang.IllegalArgumentException:
 dataSource or dataSourceClassName or jdbcUrl is required.
    at org.hibernate.hikaricp.internal.HikariCPConnectionProvider.configure (Hik
ariCPConnectionProvider.java:63)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configur
eService (StandardServiceRegistryImpl.java:100)

This used to work fine with 5.2.17.Final and we are getting this error only after upgrading to 5.3.5.Final.

This is a HIkari exception, not a Hibernate one. For more details about how to configure HikariCP, check out the User Guide.

Not sure I can agree with that. Why is Hibernate initializing the JDBC connection pool even though that useJdbc is false? In this use case there is no JDBC URL. I would dare to say that in this hase Hibernate is using Hikari in an improper manner. Therefore the exception

The needsJdbc parameter is ignored. It checked Git history and it’s been like that from the very beginning.

More, you are supposed to call execute not doExecution which should have been a protected method.

Check out this test case for more details.

Hi Vlad

doExecute in 5.3.5 is indeed public, but anyway if I look at the src of “execute”, then calling “execute” won’t make any difference in my case.

Not sure why the useJdbc was put there first place, but it would be very nice if that argument would be considered.

I’m afraid that anybody calling SchemaExport.main will get that exception, if hibernate-hikaricp is on the classpath.

Is there a Hibernate property that allows you to disable the JDBC connection pooling? I tried setting the pool size to 0 but that didn’t help.

Kind Regards,
Silvano

I didn’t write that part so I don’t have any idea what was the original purpose of that parameter.

Anyway, you need a database connection if you use the TargetType.DATABASE or if the action is update, so it’s not like setting that parameter to false will work for those two use cases.

If you can replicate your use case using this template, you should open a Jira issue to enhance the SchemaExport. We’ll have to analyze it afterward, and if the use case is valid, we could consider implementing it.

Silvano is correct. With Hibernate 5.2.x it was enough to set this:


        // set this to 0  so no connection is created on export schema.
        registryBuilder.applySetting("hibernate.connection.initial_pool_size", "0");

so that Hibernate will not create a JDBC connection pool. This is not the case with Hibernate 5.3.x. It is a change of behavior.

And this behavior is also observed even though my TargetType is SCRIPT.