diff --git a/src/main/org/guinsoo/ConnectionBuilder.java b/src/main/org/guinsoo/ConnectionBuilder.java index 8d057ff..4c7349e 100644 --- a/src/main/org/guinsoo/ConnectionBuilder.java +++ b/src/main/org/guinsoo/ConnectionBuilder.java @@ -48,6 +48,7 @@ * @author cius.ji * @since 1.8+ */ +@Deprecated public class ConnectionBuilder { /** * database url diff --git a/src/main/org/guinsoo/engine/Engine.java b/src/main/org/guinsoo/engine/Engine.java index 461d05d..9bb6650 100644 --- a/src/main/org/guinsoo/engine/Engine.java +++ b/src/main/org/guinsoo/engine/Engine.java @@ -69,20 +69,19 @@ private static SessionLocal openSession(ConnectionInfo ci, boolean ifExists, boo String p = ci.getProperty("MV_STORE"); String fileName; if (p == null) { - String store = ci.getStore(); - if (Constants.MV_DB.equals(store)) { - fileName = name + Constants.SUFFIX_MV_FILE; - } else if (Constants.PAGE_DB.equals(store)) { - fileName = name + Constants.SUFFIX_PAGE_FILE; - ci.setProperty("MV_STORE", "FALSE"); - } else if (Constants.QUICK_DB.equals(store)) { - fileName = name + Constants.SUFFIX_QUICK_FILE; - ci.setProperty("MV_STORE", "FALSE"); - } else { - throw DbException.getUnsupportedException("Unsupported DB Engine"); - } + fileName = name + Constants.SUFFIX_MV_FILE; if (!FileUtils.exists(fileName)) { - FileUtils.createFile(fileName); + fileName = name + Constants.SUFFIX_PAGE_FILE; + if (FileUtils.exists(fileName)) { + ci.setProperty("MV_STORE", "false"); + } else { + throwNotFound(ifExists, forbidCreation, name); + fileName = name + Constants.SUFFIX_OLD_DATABASE_FILE; + if (FileUtils.exists(fileName)) { + throw DbException.getFileVersionError(fileName); + } + fileName = null; + } } } else { fileName = name + (Utils.parseBoolean(p, true, false) ? Constants.SUFFIX_MV_FILE diff --git a/src/test/org/guinsoo/samples/QuickUsage.java b/src/test/org/guinsoo/samples/QuickUsage.java index 70a4614..097adf9 100644 --- a/src/test/org/guinsoo/samples/QuickUsage.java +++ b/src/test/org/guinsoo/samples/QuickUsage.java @@ -19,9 +19,8 @@ package org.guinsoo.samples; -import org.guinsoo.ConnectionBuilder; - import java.sql.Connection; +import java.sql.DriverManager; import java.sql.Statement; /** @@ -34,11 +33,9 @@ public class QuickUsage { public static void main(String[] args) throws Exception { - String url = "jdbc:guinsoo:mem:;STORE=3"; + String url = "jdbc:guinsoo:file:/Users/admin/Git/Private/grist-modeling/examples/xxx;MODE=PostgreSQL"; - Connection conn = ConnectionBuilder.getInstance() - .setUrl(url) - .build(); + Connection conn = DriverManager.getConnection(url, "sa", "sa"); Statement stmt = conn.createStatement();