我按照 h2 数据库网站上的快速入门指南创建了一个新数据库一个表并插入了一些数据。应用程序运行流畅,可以毫无问题地读写数据库。
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
现在我想用 web-frontend h2 控制台查看数据,但每次我尝试打开我的数据库时,它只会创建一个新数据库。
经过长时间的搜索,我注意到我的 Java-App,它使用 h2 嵌入式版本写入一个名为“.mv.db”的文件,而网络前端创建文件“.h2.db”(这对我)
此外,当我的应用程序写入数据库时,它会使用大量空间(约 600 个整数值需要 80MB)
如何为我的嵌入式数据库使用“.h2.db”扩展名?
最佳答案
自 1.4.177 Beta (2014-04-12) 版本起,此功能现已自动启用。
您可以通过将 ;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.
您应该告诉我们,您使用的 H2 的确切版本。
关于java - 为什么我的嵌入式 h2 程序写入 .mv.db 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23806471/