开发者

H2 console - looking at the database via browser shows old data

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

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.

For example:

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.

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

Saved Settings:开发者_Python百科 Generic H2 (Embedded)

Setting Name: Generic H2 (Embedded)

Driver Class: org.h2.Driver

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

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

Thanks in advance.

Edit

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


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

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.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜