Search code examples
javah2restore

Restore H2 database while having only a '.db' extension file


It is necessary to restore the h2 database. I have a file to recover, but its extension is .db, not .zip. I run h2 through the java -jar ./h2-1.4.190.jar -browser command. In the JDBC URL I indicate: jdbc:h2:file:/opt/backup/my.h2.db . I specify the password and login. The connection is made, I get to the database, but I don’t see my scheme. What should I do?


Solution

  • You shouldn't include a file name extension into JDBC URL. The valid URL for such file is jdbc:h2:/opt/backup/my;MV_STORE=FALSE;MVCC=FALSE.

    Please note that 1.4.190 is a very old version, use it only if the database was really created with that version. (For the latest version of H2 exclude MVCC setting from the URL, it was removed from H2.)

    Use a copy of your file. If it can't be opened normally, use a Recover Tool. https://h2database.com/html/advanced.html#using_recover_tool