}
- public PreparedStatement getTarget() {
+ public synchronized PreparedStatement getTarget() {
return target;
}
}
- public static final int CURRENT_SCHEMA_VERSION = 6;
+ public static final int CURRENT_SCHEMA_VERSION = 9;
public static final int CONNECTION_TIMEOUT = 24 * 60 * 60;
lastAction = System.currentTimeMillis();
}
- private static DatabaseConnection instance;
+ private static volatile DatabaseConnection instance;
- public static DatabaseConnection getInstance() {
+ public static synchronized DatabaseConnection getInstance() {
if (instance == null) {
- synchronized (DatabaseConnection.class) {
- if (instance == null) {
- instance = new DatabaseConnection();
- }
- }
+ instance = new DatabaseConnection();
}
return instance;
}
upgrade(version);
}
- public void beginTransaction() throws SQLException {
- c.setAutoCommit(false);
- }
-
private static void upgrade(int version) {
try {
Statement s = getInstance().c.createStatement();
}
}
- public void commitTransaction() throws SQLException {
- c.commit();
- c.setAutoCommit(true);
- }
-
- public void quitTransaction() {
- try {
- if ( !c.getAutoCommit()) {
- c.rollback();
- c.setAutoCommit(true);
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
-
public static final String preprocessQuery(String originalQuery) {
originalQuery = originalQuery.replace('`', '"');
if (originalQuery.matches("^INSERT INTO [^ ]+ SET .*")) {
return underUse.size();
}
- public void lockedStatements(PrintWriter writer) {
+ public synchronized void lockedStatements(PrintWriter writer) {
writer.println(underUse.size());
for (PreparedStatement ps : underUse) {
for (Entry<StatementDescriptor, PreparedStatement> e : statements.entrySet()) {