Helidon has extra support for using HikariCP. A DataSource instance can be easily created with MicroProfile Config and CDI.

1
2
3
4
<dependency>
<groupId>io.helidon.integrations.cdi</groupId>
<artifactId>helidon-integrations-cdi-datasource-hikaricp</artifactId>
</dependency>

The Problem

Helidon adds HikariCP 5.0.1 as a dependency. This version of HikariCP supports setting the password as a String on the DataSource. But String as a variable type for a password is more insecure than a primitive data type like a char array, see StackOverflow question Why is char[] preferred over String for passwords?. Some drivers added support for char array for setting the password and overloaded the method setPassword, f. e. the JTOpen project with the JDBC driver for DB2 on i. In case HikariCP gets the setPassword method with the char array as a parameter that will result in an IllegalArgumentException as it tries to pass the password as a string to it.

1
2
3
4
5
6
7
8
Failed to set property password on target class com.ibm.as400.access.AS400JDBCDataSource
java.lang.IllegalArgumentException: argument type mismatch
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at com.zaxxer.hikari.util.PropertyElf.setProperty(PropertyElf.java:154)
...

So depending on what of version of setPassword the Java VM returns first it will result in an IllegalArgumentException or not.

The Solution

HikariCP version 5.1.0 supports String and char array as a parameter for setPassword. To get Maven choose version 5.1.0 over the managed version of the Helidon BOM artifact you need to add the HikariCP version 5.1.0 to your POM.

Now the version 5.1.0 of HikariCP should be nearer to the root of the dependency tree than the version managed by Helidon and thus should be selected by Maven.

In Eclipse you can check this by open the pom.xml in the POM editor and open the tab Dependency Hierarchy. It displays the resolved dependencies and their versions.

1
2
3
4
5
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>5.1.0</version>
</dependency>

Happy connecting!

Mihael