提交 0baa19ed authored 作者: Thomas Mueller's avatar Thomas Mueller

The database upgrade classes have been renamed (shorter class name).

上级 bad3c174
......@@ -59,7 +59,7 @@ public class Driver implements java.sql.Driver {
}
boolean noUpgrade = StringUtils.toUpperEnglish(url).indexOf(";NO_UPGRADE=TRUE") >= 0;
url = StringUtils.replaceAllIgnoreCase(url, ";NO_UPGRADE=TRUE", "");
if (DbUpgrade.areV1dot1ClassesPresent()) {
if (DbUpgrade.areUpgradeClassesPresent()) {
if (noUpgrade) {
Connection connection = DbUpgrade.connectWithOldVersion(url, info);
if (connection != null) {
......@@ -69,7 +69,6 @@ public class Driver implements java.sql.Driver {
DbUpgrade.upgrade(url, info);
}
}
return new JdbcConnection(url, info);
} catch (Exception e) {
throw DbException.toSQLException(e);
......
......@@ -26,14 +26,14 @@ import org.h2.util.Utils;
*/
public class DbUpgrade {
private static boolean v1dot1ClassesPresent;
private static boolean upgradeClassesPresent;
private static Map<String, DbUpgradeNonPageStoreToCurrent> runningConversions;
private static Map<String, DbUpgradeFromVersion1> runningConversions;
static {
// static initialize block
v1dot1ClassesPresent = Utils.isClassPresent("org.h2.upgrade.v1_1.Driver");
runningConversions = Collections.synchronizedMap(new Hashtable<String, DbUpgradeNonPageStoreToCurrent>(1));
upgradeClassesPresent = Utils.isClassPresent("org.h2.upgrade.v1_1.Driver");
runningConversions = Collections.synchronizedMap(new Hashtable<String, DbUpgradeFromVersion1>(1));
}
/**
......@@ -41,12 +41,12 @@ public class DbUpgrade {
*
* @return true if it is
*/
public static boolean areV1dot1ClassesPresent() {
return v1dot1ClassesPresent;
public static boolean areUpgradeClassesPresent() {
return upgradeClassesPresent;
}
/**
* Connects to an old 1.1 database
* Connects to an old (version 1.1) database.
*
* @param url The connection string
* @param info The connection properties
......@@ -98,23 +98,19 @@ public class DbUpgrade {
* @throws SQLException
*/
public static synchronized void upgrade(String url, Properties info) throws SQLException {
if (v1dot1ClassesPresent) {
upgradeFromNonPageStore(url, info);
}
}
private static void upgradeFromNonPageStore(String url, Properties info) throws SQLException {
if (runningConversions.containsKey(url)) {
// do not migrate, because we are currently migrating, and this is
// the connection where "runscript from" will be executed
return;
}
try {
DbUpgradeNonPageStoreToCurrent instance = new DbUpgradeNonPageStoreToCurrent(url, info);
runningConversions.put(url, instance);
instance.upgrade();
} finally {
runningConversions.remove(url);
if (upgradeClassesPresent) {
if (runningConversions.containsKey(url)) {
// do not migrate, because we are currently migrating, and this is
// the connection where "runscript from" will be executed
return;
}
try {
DbUpgradeFromVersion1 instance = new DbUpgradeFromVersion1(url, info);
runningConversions.put(url, instance);
instance.upgrade();
} finally {
runningConversions.remove(url);
}
}
}
......
......@@ -20,10 +20,10 @@ import org.h2.util.StringUtils;
import org.h2.util.Utils;
/**
* Class to convert a 1.1 DB (non page store) to a 1.2 DB (page store) format.
* Conversion is done via "script to" and "runscript from".
* Class to convert a 1.1 database (non page store) to the 1.2 (page store)
* format. Conversion is done via "script to" and "runscript from".
*/
public class DbUpgradeNonPageStoreToCurrent {
public class DbUpgradeFromVersion1 {
private static boolean scriptInTmpDir;
private static boolean deleteOldDb;
......@@ -53,7 +53,7 @@ public class DbUpgradeNonPageStoreToCurrent {
* @param info The connection properties
* @throws SQLException if an exception occurred
*/
public DbUpgradeNonPageStoreToCurrent(String url, Properties info) throws SQLException {
public DbUpgradeFromVersion1(String url, Properties info) throws SQLException {
this.url = url;
this.info = info;
init();
......@@ -216,7 +216,7 @@ public class DbUpgradeNonPageStoreToCurrent {
* located in the temp directory.
*/
public static void setScriptInTmpDir(boolean scriptInTmpDir) {
DbUpgradeNonPageStoreToCurrent.scriptInTmpDir = scriptInTmpDir;
DbUpgradeFromVersion1.scriptInTmpDir = scriptInTmpDir;
}
/**
......@@ -227,7 +227,7 @@ public class DbUpgradeNonPageStoreToCurrent {
* @param deleteOldDb if true, the old db files will be deleted.
*/
public static void setDeleteOldDb(boolean deleteOldDb) {
DbUpgradeNonPageStoreToCurrent.deleteOldDb = deleteOldDb;
DbUpgradeFromVersion1.deleteOldDb = deleteOldDb;
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论