1
votes

I am trying to implement Hikari Connection Pooling(v 2.3.5). I have everything setup and I am able to retrieve the connection from the pool, and setup a preparedstatement object. Whenever I try to perform any operation on the prepared statement, Hikari throws an internal NPE.

Data Warehouse Task Error
com.hs.task.warehouse.eci.EciConversionException: Failed while converting claims...
    at com.hs.task.warehouse.eci.Claims.convertTable(Claims.java:253)
    at com.hs.task.warehouse.DataWarehouseTask.execute(DataWarehouseTask.java:76)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.NullPointerException
    at com.zaxxer.hikari.proxy.PreparedStatementJavassistProxy.setString(PreparedStatementJavassistProxy.java)
    at com.hs.task.warehouse.eci.Claims.convertTable(Claims.java:68)
    ... 3 more

I am using a very old JDBC driver to a proprietary DB. I have previously used Proxool with this same driver without issue.

Configuration:

HikariConfig hconf = new HikariConfig();
                hconf.setDriverClassName("com.dbcswc.fs.jdbc.Driver");
                hconf.setJdbcUrl("=jdbc:fs3:MyServer:9584/MyDB;encryption=off;localport=0");
                hconf.setUsername("user");
                hconf.setPassword("pass");
                hconf.setConnectionTestQuery("select 1 as test from pu");

Here is where the error is happening

PreparedStatement psClaims = con.prepareStatement(sql);
psClaims.setString(1, ECI_DT_FMT.format(lastConvertDate));

psClaims is NOT NULL at this point when the setString is called.

1
Is ECI_DT_FMT.format(lastConvertDate) returning null?brettw
Please open an issue on the HikariCP project page, it will be easier to track and debug there.brettw

1 Answers

0
votes

For the sake of simplicity, I changed this line of code in the post:

PreparedStatement psClaims = con.prepareStatement(sql);

The prepared statement was being obtained by another class that was sending the autoGeneratedKeys parameter to the driver:

con.prepareStatement(sql, PreparedStatement.NO_GENERATED_KEYS)

After some debugging, I found out that the driver was returning a NULL preparedstatement, BUT HikariCP still returned a PreparedStatement proxy object. HikariCP was holding the reference to the NULL preparedstatement obtained from the driver and threw a NPE whenever the preparedstatement was being acted on, such as, setString().

I am not even sure if it is legal for the driver to return NULL, I would lean to it being a bug in the driver so I am not sure if it should be addressed in HikariCP or not. I will raise an issue there with the details and see if they would like to put a check in for that situation.