Hi,

I'm sorry for the delay.

I have a reproducible test case, and I tried to fix the problem, but
unfortunately it's not so easy... I believe it would require a change
in the migration jar file. This is problematic however. I'm afraid the
only solution I have for now is to not use the system property
"h2.baseDir" in this case.

Regards,
Thomas

P.S. my test case:

System.setProperty("h2.baseDir", "~/temp");
Class.forName("org.h2.upgrade.v1_1.Driver");
Connection conn =
DriverManager.getConnection("jdbc:h2v1_1:test;page_store=false");
conn.createStatement().execute("create table test(id int)");
conn.close();
Class.forName("org.h2.Driver");
conn = DriverManager.getConnection("jdbc:h2:test");
conn.createStatement().executeQuery("select * from test");
conn.close();

My patch (does not solve the problem unfortunately):

Index: src/main/org/h2/upgrade/DbUpgrade.java
===================================================================
--- src/main/org/h2/upgrade/DbUpgrade.java      (revision 3585)
+++ src/main/org/h2/upgrade/DbUpgrade.java      (working copy)
@@ -13,6 +13,7 @@
 import java.sql.Statement;
 import java.util.Properties;
 import java.util.UUID;
+import org.h2.constant.SysProperties;
 import org.h2.engine.ConnectionInfo;
 import org.h2.jdbc.JdbcConnection;
 import org.h2.message.DbException;
@@ -60,6 +61,10 @@
         if (ci.isRemote() || !ci.isPersistent()) {
             return null;
         }
+        String baseDir = SysProperties.getBaseDir();
+        if (baseDir != null) {
+            ci.setBaseDir(baseDir);
+        }
         String name = ci.getName();
         if (IOUtils.exists(name + ".h2.db")) {
             return null;
@@ -71,7 +76,7 @@
             return connectWithOldVersion(url, info);
         }
         synchronized (DbUpgrade.class) {
-            upgrade(ci, info);
+            upgrade(url, name, info);
             return null;
         }
     }
@@ -104,8 +109,7 @@
         return DriverManager.getConnection(url, info);
     }

-    private static void upgrade(ConnectionInfo ci, Properties info)
throws SQLException {
-        String name = ci.getName();
+    private static void upgrade(String url, String name, Properties
info) throws SQLException {
         String data = name + ".data.db";
         String index = name + ".index.db";
         String lobs = name + ".lobs.db";
@@ -120,7 +124,8 @@
             } else {
                 script = name + ".script.sql";
             }
-            String oldUrl = "jdbc:h2v1_1:" + name +
";UNDO_LOG=0;LOG=0;LOCK_MODE=0";
+            ConnectionInfo ci = new ConnectionInfo(url, info);
+            String oldUrl = "jdbc:h2v1_1:" + ci.getName() +
";UNDO_LOG=0;LOG=0;LOCK_MODE=0";
             String cipher = ci.getProperty("CIPHER", null);
             if (cipher != null) {
                 oldUrl += ";CIPHER=" + cipher;

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to