为什么我的嵌入式 h2 程序写入 .mv.db 文件 [英] Why is my embedded h2 program writing to a .mv.db file

查看:22
本文介绍了为什么我的嵌入式 h2 程序写入 .mv.db 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照 h2 数据库网站上的快速入门指南创建了一个新数据库一个表并插入了一些数据.应用程序运行流畅,可以毫无问题地读写数据库.

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.

  • 将 h2*.jar 添加到类路径(H2 没有任何依赖项)
  • 使用 JDBC 驱动程序类:org.h2.Driver
  • 数据库 URL jdbc:h2:~/test 在您的用户主目录中打开数据库测试
  • 自动创建一个新数据库

现在我想使用 web-frontend h2 控制台查看数据,但每次我尝试打开我的数据库时,它只会创建一个新数据库.

经过长时间的搜索,我注意到我使用 h2 嵌入式版本的 Java-App 写入了一个名为.mv.db"的文件.而网络前端创建文件.h2.db";(这对我来说更有意义)

此外,当我的应用程序写入数据库时​​,它使用了大量空间(80MB 用于 ~600 个整数值)
我如何使用.h2.db"?我的嵌入式数据库的扩展?

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?

推荐答案

自版本 1.4.177 Beta (2014-04-12) 起,此功能现已自动启用.

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

您可以通过在数据库 URL 中添加 ;MV_STORE=FALSE;MVCC=FALSE 来禁用它

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

默认情况下,启用了 MV_STORE 选项,因此它使用新的MVStore 存储.MVCC 设置默认设置为相同的值作为 MV_STORE 设置,所以它也是默认启用的.为了测试,可以通过附加;MV_STORE=FALSE"来禁用这两个设置和/或;MVCC=FALSE"到数据库 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

您应该告诉我们您使用的 H2 的确切版本.

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

这篇关于为什么我的嵌入式 h2 程序写入 .mv.db 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆