I followed the quickstart guide on the h2 database website to create a new database a table and insert some data. The application runs smooth and can read and write to the database without problems.

Quickstart h2

  • Add the h2*.jar to the classpath (H2 does not have any dependencies)
  • Use the JDBC driver class: org.h2.Driver
  • The database URL jdbc:h2:~/test opens the database test in your user home directory
  • A new database is automatically created

Now i want to look at the data with the web-frontend h2 console but everytime I try to open my database it just creates a new database.

After a long search I noticed that my Java-App, which uses the h2 embedded version writes to a file called ".mv.db" while the web-frontend creates the file ".h2.db" (which makes much more sense for me)

Also when my App writes to the database it uses extreme amounts of space (80MB for ~600 integer values)
How can I use the ".h2.db" extension for my embedded database?

share|improve this question
2  
Are you using the 1.4.x beta release, or the stable 1.3.x? Knowing which specific version of H2 you're using will narrow this down quite a bit. – Craig Otis May 22 '14 at 18:18
up vote 35 down vote accepted

This is now automatically enabled since version 1.4.177 Beta (2014-04-12).

You can disable it by adding ;MV_STORE=FALSE and ;MVCC=FALSE to the database URL

By default, the MV_STORE option is enabled, so it is using the new MVStore storage. The MVCC setting is by default set to the same values as the MV_STORE setting, so it is also enabled by default. For testing, both settings can be disabled by appending ";MV_STORE=FALSE" and/or ";MVCC=FALSE" to the database URL.

http://www.h2database.com/html/changelog.html

You should tell us, what exact version of H2 you use.

share|improve this answer
    
Thank you, that solved it. I unknowingly used the beta version and after downgrading the library to the latest stable it worked nice. – FelixZett May 25 '14 at 12:57

.mv.db-files are for the upcoming/beta storage type "MVStore" for H2.

Here is from the http://www.h2database.com/html/changelog.html:

New table engine "org.h2.mvstore.db.MVTableEngine" that internally uses the MVStore to persist data. To try it out, append ";DEFAULT_TABLE_ENGINE=org.h2.mvstore.db.MVTableEngine" to the database URL. This is still very experimental, and many features are not supported yet. The data is stored in a file with the suffix .mv.db.

share|improve this answer
    
This is the only line I found about that too, still I have never appended this argument anywhere... – FelixZett May 22 '14 at 13:08
1  
The MVStore storage is now the default in version 1.4.x beta. – Thomas Mueller May 24 '14 at 11:18
    
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. – bob Dec 3 '15 at 11:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.