How to check h2 database health and corruption

2019-07-08 08:33发布

问题:

I'm using h2 database in embedded mode with JavaFX 8 desktop application and I have developed an option for the user to backup and restore the database file.

In the older version of the program I have used SQLite database and checking the database file was quite simple using this command pragma integrity_check.

Using that command with the h2 database always throws an exception.

What is the alternative for that in the h2 database? And is there an explicit or more proper way to check the h2 database file before using it?

Any help or code sample is appreciated,thanks.

回答1:

What you could do is execute the script to command, for example with compression. If that command works, then the database is good. At the same time, you have a backup.