# HikariCP: IllegalArgumentException: dataSource or dataSourceClassNa or jdbcUrl is required

**URL:** <https://discourse.hibernate.org/t/hikaricp-illegalargumentexception-datasource-or-datasourceclassna-or-jdbcurl-is-required/1312>\
**Category:** Hibernate ORM\
**Created:** [August 30, 2018, 12:33pm UTC](https://discourse.hibernate.org/t/hikaricp-illegalargumentexception-datasource-or-datasourceclassna-or-jdbcurl-is-required/1312 "2018-08-30T12:33:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Silvano\_Maffeis](https://avatars.discourse-cdn.com/v4/letter/s/e9a140/32.png) [@Silvano\_Maffeis](https://discourse.hibernate.org/u/Silvano_Maffeis)\
**Post date:** [August 30, 2018, 12:33pm UTC](https://discourse.hibernate.org/t/hikaricp-illegalargumentexception-datasource-or-datasourceclassna-or-jdbcurl-is-required/1312/1 "2018-08-30T12:33:30Z")

</div>

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:

```auto
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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [August 30, 2018, 12:40pm UTC](https://discourse.hibernate.org/t/hikaricp-illegalargumentexception-datasource-or-datasourceclassna-or-jdbcurl-is-required/1312/2 "2018-08-30T12:40:44Z")

</div>

This is a HIkari exception, not a Hibernate one. For more details about how to configure HikariCP, check out the [User Guide](http://docs.jboss.org/hibernate/orm/5.3/userguide/html_single/Hibernate_User_Guide.html#database-connectionprovider-hikari).

---

<div class="post-metadata">

**Author:** ![Silvano\_Maffeis](https://avatars.discourse-cdn.com/v4/letter/s/e9a140/32.png) [@Silvano\_Maffeis](https://discourse.hibernate.org/u/Silvano_Maffeis)\
**Post date:** [August 30, 2018, 12:56pm UTC](https://discourse.hibernate.org/t/hikaricp-illegalargumentexception-datasource-or-datasourceclassna-or-jdbcurl-is-required/1312/3 "2018-08-30T12:56:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [August 30, 2018, 1:06pm UTC](https://discourse.hibernate.org/t/hikaricp-illegalargumentexception-datasource-or-datasourceclassna-or-jdbcurl-is-required/1312/4 "2018-08-30T13:06:11Z")

</div>

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](https://github.com/hibernate/hibernate-orm/blob/e5dc635a52362f69b69acb8d5b166b69b165dbbd/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/tools/SchemaExportTest.java) for more details.

---

<div class="post-metadata">

**Author:** ![Silvano\_Maffeis](https://avatars.discourse-cdn.com/v4/letter/s/e9a140/32.png) [@Silvano\_Maffeis](https://discourse.hibernate.org/u/Silvano_Maffeis)\
**Post date:** [August 30, 2018, 1:53pm UTC](https://discourse.hibernate.org/t/hikaricp-illegalargumentexception-datasource-or-datasourceclassna-or-jdbcurl-is-required/1312/5 "2018-08-30T13:53:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vlad](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/vlad/32/658_2.png) [@vlad](https://discourse.hibernate.org/u/vlad)\
**Post date:** [August 30, 2018, 1:59pm UTC](https://discourse.hibernate.org/t/hikaricp-illegalargumentexception-datasource-or-datasourceclassna-or-jdbcurl-is-required/1312/6 "2018-08-30T13:59:46Z")

</div>

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](https://github.com/hibernate/hibernate-test-case-templates), 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.

---

<div class="post-metadata">

**Author:** ![ptahchiev](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/ptahchiev/32/697_2.png) [@ptahchiev](https://discourse.hibernate.org/u/ptahchiev)\
**Post date:** [July 14, 2019, 7:52am UTC](https://discourse.hibernate.org/t/hikaricp-illegalargumentexception-datasource-or-datasourceclassna-or-jdbcurl-is-required/1312/7 "2019-07-14T07:52:08Z")

</div>

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

```auto

        // 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.

---

<div class="post-metadata">

**Author:** ![ptahchiev](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/ptahchiev/32/697_2.png) [@ptahchiev](https://discourse.hibernate.org/u/ptahchiev)\
**Post date:** [July 14, 2019, 7:56am UTC](https://discourse.hibernate.org/t/hikaricp-illegalargumentexception-datasource-or-datasourceclassna-or-jdbcurl-is-required/1312/8 "2019-07-14T07:56:12Z")

</div>

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