Skip to content

Commit

Permalink
feat: deprecated store engine optional arg
Browse files Browse the repository at this point in the history
  • Loading branch information
ciusji committed Nov 19, 2022
1 parent 8401659 commit b94e3af
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/main/org/guinsoo/ConnectionBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
* @author cius.ji
* @since 1.8+
*/
@Deprecated
public class ConnectionBuilder {
/**
* database url
Expand Down
25 changes: 12 additions & 13 deletions src/main/org/guinsoo/engine/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 3 additions & 6 deletions src/test/org/guinsoo/samples/QuickUsage.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@

package org.guinsoo.samples;

import org.guinsoo.ConnectionBuilder;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
Expand All @@ -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();

Expand Down

0 comments on commit b94e3af

Please sign in to comment.