How to access *.mv.db file of H2 database?
Asked Answered
H

3

18

I have created database with my own program and it appeared as mydatabase.mv.db file.

But when I tried to access the same database with DbVisualizer, with apparently same parameters, it created two files mydatabase.lock.db and celebrity.h2.db and didn't see tables, created in the program.

What was the incompatibility?

UPDATE

both setups are follows:

enter image description here

enter image description here

Horwath answered 24/11, 2014 at 0:51 Comment(3)
What are the connection details you are using for your program and DbVisualizer?Desimone
Try and make sure the path is using / and not ` (in DbVisualizer`)Desimone
For convenience, append ;IFEXISTS=TRUE to avoid creating spurious database files, as suggested here.Torrez
B
21

In H2 version 1.3.x, the database file <databaseName>.h2.db is the default. (The storage engine "PageStore" is used).

In H2 version 1.4.x, the database file <databaseName>.mv.dbis the default. (The storage engine "MVStore" is used). The MVStore is still beta right now (November 2014). But you can disable the MVStore by appending ;mv_store=false to the database URL.

Bedraggled answered 24/11, 2014 at 8:32 Comment(4)
i can confirm the 1.4.190 version of h2 will create a <databaseName>.h2.db instead of <databaseName>.mv.db(even i set MVCC=TRUE;MULTI_THREADED=TRUE in jdbc url). what i have to do is set MC_STORE=TRUE to force h2 use <databaseName>.mv.db file.Interferometer
I think you are using an older version 1.4.190, or the database already existed. Could you check by running select * from information_schema.settings where name like '%BUILD%'? With version 1.4.190 you will get 190 twice as the result (CREATE_BUILD is the build that was used to create the database, and info.BUILD_ID is the current version). By the way it is MV_STORE not MC_STORE.Bedraggled
sorry, i find out it was caused by the database has been created before(without MVCC=TRUE). if the <databaseName>.h2.db exist, it seems h2 will reuse the older one rather create new one called <databaseName>.mv.db.Interferometer
Yes if a database (created by an older version) already exists, it is used.Bedraggled
L
7

The accepted answer is now several years old and since others may be looking for a more "current" solution...

To get it to work just update the H2 JDBC driver that DBVizualizer uses. Basically download the "Platform-Independent Zip" from http://www.h2database.com/html/download.html and copy the h2/bin/h2-X.X.X.jar file to ~/.dbvis/jdbc/ and then restart DBVizualizer so it can pick up the updated driver.

Also, make sure you remove .mv.db from the file name when setting the Database file name in DBVizualizer.

Laina answered 23/5, 2017 at 17:36 Comment(0)
S
1

For Windows Users: The excellent way to read a *.db.mv file would be locally installing the h2 database and then running that database locally with the java command. Then your path to the file will definitely show the data from your table until and unless any errors occur.

You can download the h2 database form: http://www.h2database.com/html/download-archive.html Note: choose the database version for H2 which supports your file. You can install the H2 database by installing the downloaded .exe file would be around 7 MB.

then in the bin directory of H2 open a command prompt and run the command java -jar in my case it is

command: java -jar h2-1.4.200.jar

It will show the console of the H2 database on the browser

Provide the database details: Driver Class: org.h2.Driver JDBC URL: jdbc:h2:~/h2 "file path" User Name: "blank by default" Password: "blank by default"

Refer SS below enter image description here

Shoelace answered 27/10, 2022 at 12:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.