HikariCP: IllegalArgumentException: dataSource or dataSourceClassNa or jdbcUrl is required


#1

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.


#2

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


#3

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


#4

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.


#5

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


#6

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.