Can't get H2 1.4.193 in embedded mode to connect to existing ~/test.mv.db

189 views
Skip to first unread message

brink...@gmail.com

unread,
Nov 6, 2016, 1:19:47 AM11/6/16
to H2 Database

I successfully created ~/test.mv.db, added tables, and inserted data using the 1.4.193 web console.  Tables and data are still visible in the web console when I reopen it:

By my reading of the H2 documentation and some answers to similar problems, calling a URL like
"jdbc:h2:~/test;IFEXISTS=TRUE"
should cause H2 to reconnect to the existing ~/test.mv.db. But every time I attempt to read the existing data from the JVM application, H2 creates a new ~/test.h2.db instead, and then (not surprisingly) fails with a "Table not found" error:

I'm using H2 with highly abstract code from the doobie library for Scala, but I'm nearly certain the issue here is due to my inexperience with H2 and not anything on the Scala side.

FYI in case it makes any difference, my H2 JAR file is in a sub-subdirectory of ~/.


Evgenij Ryazanov

unread,
Nov 6, 2016, 3:26:25 AM11/6/16
to H2 Database
If you started your database on H2 Server, you should use jdbc:h2:tcp://localhost/~/test as database URL on client side for Client/Server mode. Your URL suitable only for H2 Console and for embedded mode.

Anyway, this behaviour is strange. Is it possible that you have an older h2 jar somewhere in classpath of your application?

brink...@gmail.com

unread,
Nov 6, 2016, 7:18:05 PM11/6/16
to H2 Database
This was in embedded mode.  The H2 1.4.193 JAR I downloaded for this work is the only one I ever explicitly downloaded, although I have run numerous Play framework samples that included an embedded H2.  FYI, I have never run an explicit install procedure for H2 -- just downloaded the jar, invoked included script for web client, and called in embedded mode from my project.  I have no explicit CLASSPATH in env, and am not explicitly supplying any CLASSPATH argument when I run the project.  This is on Ubuntu 16.04.

Noel Grandin

unread,
Nov 8, 2016, 3:09:05 PM11/8/16
to h2-da...@googlegroups.com
that looks like you are using an old version of H2 in your application, which is opening a database based on the PageStore engine, hence the .h2.db file extension.

the web console is running a newer version, and is defaulting to the MVStore engine, hence the .mv.db file extension
Reply all
Reply to author
Forward
0 new messages