H2控制台-通过浏览器查看数据库显示旧数据 [英] H2 console - looking at the database via browser shows old data

查看:241
本文介绍了H2控制台-通过浏览器查看数据库显示旧数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 H2数据库用于简单的Web应用程序.

I'm using H2 database for a simple web application.

当我尝试通过H2控制台Web浏览器查看数据时,它似乎没有使用数据库中的最新数据进行更新.

When I try and view the data via the H2 console web browser, it doesn't seem to update with the latest data in the database.

例如:

我使用Web应用程序将新记录添加到表中,并且当我在将记录添加到的表中执行select *时,它不会显示新记录.

I add a new record to a table using my web app and when I do a select * from the table I added the record to, it doesn't show the new record.

通过浏览器连接到H2控制台时,我具有以下登录名设置:

I have the following settings for the Login when I connect to H2 console via the browser:

保存的设置:通用H2(嵌入式)

Saved Settings: Generic H2 (Embedded)

设置名称:通用H2(嵌入式)

Setting Name: Generic H2 (Embedded)

驱动程序类:org.h2.Driver

Driver Class: org.h2.Driver

JDBC URL:jdbc:h2:file:/Develops/Databases/snowy_db; FILE_LOCK = NO

JDBC URL: jdbc:h2:file:/Develops/Databases/snowy_db;FILE_LOCK=NO

关于如何使用H2控制台浏览器从数据库访问最新数据的任何想法?

Any ideas on how I go about accessing the latest data from the database using the H2 console browser?

谢谢.

修改

只需添加:我可以在Web应用程序中看到新记录,但在使用H2控制台浏览器时看不到.

Just to add: I can see the new record in my web app but not when I use the H2 console browser.

推荐答案

我猜您的问题是FILE_LOCK=NO选项. 文档对此声明如下:

I guess your problem is FILE_LOCK=NO option. The documentation states about it that:

由应用程序来保护数据库文件.否则,将导致数据库损坏. [...]请注意,这是不安全的,因为另一个进程能够打开同一数据库,可能导致数据损坏

it is up to the application to protect the database files. Failing to do so will result in a corrupted database. [...] Please note that this is unsafe as another process is able to open the same database, possibly leading to data corruption

我强烈建议您使用更复杂的H2模式,例如 自动混合模式 .在这种模式下,连接到给定数据库的第一个应用程序将打开一个套接字服务器,随后从其他应用程序连接到该数据库的所有尝试都将使用套接字连接,而不是原始文件系统访问.

I am strongly recommending you to use more sophisticated H2 mode like automatic mixed mode. In this mode the first application that connects to a given database opens a socket server and every subsequent attempt to connect to this database from other applications uses socket connection rather than raw file system access.

如果您对此不满意,只需将H2作为独立服务器运行或在Seam应用程序中运行.然后更改您的JDBC URL,以使其通过localhost和TCP连接进行连接.

If you don't feel comfortable with that, just run H2 as a standalone server separately or inside your Seam application. Then change your JDBC URL so that it connects via localhost and TCP connection.

这篇关于H2控制台-通过浏览器查看数据库显示旧数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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