在Web控制台中看不到我的H2数据库 [英] Can't see my H2 database in Web Console

查看:232
本文介绍了在Web控制台中看不到我的H2数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下URL用代码创建了一个H2数据库:

I created a H2 database with my code with this URL:

jdbc:h2:C:/data/fixed.db

jdbc:h2:C:/data/fixed.db

我的代码可以创建表,执行查询.如果手动打开文件,则可以成功查看其内容并查看创建查询等

My code can create tables, perform queries. If I open the file manually, I can successfully see its content and view the create queries etc

但是,当我尝试通过Web界面使用H2控制台时,看不到数据库.而是,Web控制台在C:/data/fixed.db.mv.db处创建另一个空数据库.我只是无法加载我的数据库.

However, when I try to use H2 console with the web interface, I can't see the database. Instead, the web console create another empty database located here C:/data/fixed.db.mv.db. I just can't load my database.

我想念什么?

编辑

我的代码使用H2 1.3.175
Web控制台H2 1.4.178

My code uses H2 1.3.175
The web console H2 1.4.178

推荐答案

最后,我解决了我的问题...

Finally I solved my problem...

从1.4.x开始,H2使用MV_STORE(请参见此处和Thomas Mueller的评论). 显然,Web控制台尝试自动附加.mv.db扩展名.即使已经有一个扩展名为h2.db的文件.

Since 1.4.x, H2 uses MV_STORE (see SO answer here and Thomas Mueller comment). Apparently, the web console tries to append automatically a .mv.db extension. Even if there is already a file with the h2.db extension.

因此,我将代码的H2版本从1.3.175升级到1.4.178,最后,我可以看到我的数据了...

So , I upgrade the H2 version of my code from 1.3.175 to 1.4.178 and finally, I can see my data...

编辑
这是 @devdanke 提出的替代解决方案:

EDIT
Here is an alternative solution proposed by @devdanke:

您必须手动告诉H2 1.4.x不要使用MV_Store:; mv_store = false".真麻烦.

You must manually tell your H2 1.4.x not to use MV_Store: ";mv_store=false". What a hassle.

例如,您将以类似以下代码的结尾:

For example, you would end with a code similar to:

Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection( //
    "jdbc:h2:file:C:\\my\\java\\projects\\test;mv_store=false" //
);

这篇关于在Web控制台中看不到我的H2数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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