HikariConfig config = new HikariConfig();
config.setDataSourceClassName("org.h2.jdbcx.JdbcDataSource");
config.setConnectionTestQuery("VALUES 1");
config.addDataSourceProperty("URL", "jdbc:h2:~/test");
config.addDataSourceProperty("user", "sa");
config.addDataSourceProperty("password", "sa");
HikariDataSource ds = new HikariDataSource(config);
I had no trouble connecting with this configuration. Basically, Hikari will append "set" to whatever property name you give, so "URL" becomes "setURL" when invoked. Any method on a DataSource that follows the "setXYX()" convention for method names can be invoked by Hikari. This is pretty standard Java practice, and I have yet to find a DataSource it doesn't work with.
With regard to internal pool statistics, there is a JMX MBean available that exposes:
* Idle Connection count
* Active Connections (in use)
* Total Connections
* The number of threads waiting for a connection
You can see these values through a JMX console like JConsole. Or you can lookup the MBean yourself.
The MBean is registered with the name:
com.zaxxer.hikari:type=Pool (<poolName>)
where poolName is a name you can set on the HikariConfig using config.setPoolName("foo"), for example.
Off the top of my head, you can do something like:
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName poolName = new ObjectName("com.zaxxer.hikari:type=Pool (foo)");
Integer idleConnections = (Integer) mBeanServer.getAttribute(poolName, "IdleConnections");