如何检查H2数据库是否需要升级? [英] How to check if a h2 database needs to be upgraded?

查看:264
本文介绍了如何检查H2数据库是否需要升级?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

H2下载站点上,有一个Database Upgrade Helper File用于从1.1升级到较新版本.我想知道是否有一种很好的方法来检查数据库是否需要升级.到目前为止,我正在做的是使用新驱动程序打开与旧数据库的连接,捕获异常,然后进行迁移.如果可能的话,我想用Java进行检查.

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.

推荐答案

如果类路径中有Database Upgrade Helper File,并且该数据库是使用H2版本1.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.

除此之外,您无需升级数据库,因为自H2 1.2版以来,数据库文件没有更改(使用1.2.x版创建的数据库可以使用最新版本打开).至少那是计划.如果在某些情况下不起作用,请告诉我们问题出在哪里.

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.

这篇关于如何检查H2数据库是否需要升级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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