问题
On H2 download site there is a Database Upgrade Helper File for upgrading from 1.1 to a newer version. I wonder if there a nice and clean way of checking if a database needs to upgraded. What I was doing so far was opening a connection to an old db with a new driver, catching the exception and then doing the migration. I would like to do the check in Java if possible.
回答1:
If you have the Database Upgrade Helper File in your classpath, and the database was created with H2 version 1.1, then the database is automatically upgraded.
Other than that, you don't need to upgrade the database, as the database file didn't change since H2 version 1.2 (databases created with version 1.2.x can be opened with the most recent version). At least, that's the plan. If it doesn't work in some case, then please tell us what the problem is.
来源:https://stackoverflow.com/questions/15094815/how-to-check-if-a-h2-database-needs-to-be-upgraded