|
|
|
|
@ -7,6 +7,7 @@ import java.sql.SQLException;
@@ -7,6 +7,7 @@ import java.sql.SQLException;
|
|
|
|
|
|
|
|
|
|
import static de.srsoftware.tools.jdbc.Condition.equal; |
|
|
|
|
import static de.srsoftware.tools.jdbc.Query.replaceInto; |
|
|
|
|
import static de.srsoftware.tools.jdbc.Query.update; |
|
|
|
|
import static de.srsoftware.umbrella.core.Constants.*; |
|
|
|
|
import static de.srsoftware.umbrella.core.Constants.TABLE_SETTINGS; |
|
|
|
|
import static java.lang.System.Logger.Level.ERROR; |
|
|
|
|
@ -14,7 +15,7 @@ import static java.lang.System.Logger.Level.INFO;
@@ -14,7 +15,7 @@ import static java.lang.System.Logger.Level.INFO;
|
|
|
|
|
import static java.text.MessageFormat.format; |
|
|
|
|
|
|
|
|
|
public abstract class BaseDb { |
|
|
|
|
private final System.Logger LOG = System.getLogger(getClass().getSimpleName()); |
|
|
|
|
private final System.Logger LOG = System.getLogger(getClass().getInterfaces()[0].getSimpleName()); |
|
|
|
|
|
|
|
|
|
protected final Connection db; |
|
|
|
|
|
|
|
|
|
@ -61,4 +62,18 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255)
@@ -61,4 +62,18 @@ CREATE TABLE IF NOT EXISTS {0} ( {1} VARCHAR(255) PRIMARY KEY, {2} VARCHAR(255)
|
|
|
|
|
} |
|
|
|
|
return version; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void swapStates(String table) { |
|
|
|
|
try { |
|
|
|
|
db.setAutoCommit(false); |
|
|
|
|
update(table).set(STATUS).where(STATUS,equal(40)).prepare(db).apply(0).execute(); |
|
|
|
|
update(table).set(STATUS).where(STATUS,equal(20)).prepare(db).apply(40).execute(); |
|
|
|
|
update(table).set(STATUS).where(STATUS,equal(10)).prepare(db).apply(20).execute(); |
|
|
|
|
update(table).set(STATUS).where(STATUS,equal(0)).prepare(db).apply(10).execute(); |
|
|
|
|
db.setAutoCommit(true); |
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|