I've got the following code to start an H2 daemon and connect to it with Hikari:
// Start H2 daemon
server = Server.createTcpServer("-tcpDaemon").start();
// Connect Hikari to H2 server
HikariConfig hkConfig = new HikariConfig();
hkConfig.setDriverClassName("org.h2.Driver");
hkConfig.setJdbcUrl("jdbc:h2:" + server.getURL() + "/./ghost;MODE=MySQL;IFEXISTS=false");
...
However, even though IFEXISTS
is set to false
in the JDBC URL, I still get the following exception during pool initialization:
org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database "C:/Users/Cole/IdeaProjects/ghost2/ghost" not found, and IFEXISTS=true, so we cant auto-create it
I tried connecting the 'normal' way with DriverManager
to no avail. The same exception was thrown. Is there a different, working way to configure H2 features that I don't know about, or am I doing something wrong?
This appears to be a badly-written error message. See issue #1894 for details.
Strangely enough, this issue doesn't occur in <=1.4.197. The same exact code posted above works. As far as I can tell from #1766, this is a security issue that has been patched.