Skip to content

Commit 12f7495

Browse files
committed
fix(database): Fix set autocommit = true when should be false
1 parent fd3448a commit 12f7495

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

src/main/java/com/dre/brewery/storage/impls/MySQLStorage.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ public MySQLStorage(ConfiguredDataManager record) throws StorageInitException {
8282

8383

8484
try (Connection connection = source.getConnection()) {
85-
try (PreparedStatement statement = connection.prepareStatement("USE " + record.getDatabase())) {
86-
statement.execute();
87-
}
88-
8985
for (String table : TABLES) {
9086
try (PreparedStatement statement = connection.prepareStatement("CREATE TABLE IF NOT EXISTS " + tablePrefix + table)) {
9187
statement.execute();
@@ -168,10 +164,9 @@ public <T extends SerializableThing> void saveAllGeneric(List<T> serializableThi
168164
String deleteOldRecordsSql = "DELETE FROM " + tablePrefix + table + " WHERE id NOT IN (SELECT id FROM temp_" + table + ")";
169165

170166
try (Connection connection = source.getConnection()) {
171-
167+
connection.setAutoCommit(false);
172168
try (PreparedStatement createTempTableStmt = connection.prepareStatement(createTempTableSql);
173169
PreparedStatement insertTempTableStmt = connection.prepareStatement(insertTempTableSql)) {
174-
175170
createTempTableStmt.execute();
176171

177172
for (SerializableThing serializableThing : serializableThings) {

0 commit comments

Comments
 (0)