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