1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-07 00:38:42 +01:00

Remove async operation from sql connection, it does not allows

Fixes #921
This commit is contained in:
montlikadani 2020-09-13 19:57:44 +02:00
parent 274bc6e561
commit 02d8fa4053
2 changed files with 21 additions and 35 deletions

View File

@ -2,7 +2,6 @@ package com.gamingmesh.jobs.dao;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.concurrent.CompletableFuture;
public class JobsConnectionPool { public class JobsConnectionPool {
@ -25,31 +24,23 @@ public class JobsConnectionPool {
connection = null; connection = null;
} }
CompletableFuture.supplyAsync(() -> { if (connection == null) {
if (connection == null) { try {
try { connection = new JobsConnection(DriverManager.getConnection(url, username, password));
connection = new JobsConnection(DriverManager.getConnection(url, username, password)); } catch (SQLException e) {
} catch (SQLException e) {
}
} }
}
return true;
});
return connection; return connection;
} }
public void closeConnection() { public synchronized void closeConnection() {
CompletableFuture.supplyAsync(() -> { if (connection != null) {
if (connection != null) { try {
try { connection.closeConnection();
connection.closeConnection(); } catch (SQLException e) {
} catch (SQLException e) { e.printStackTrace();
e.printStackTrace();
}
} }
}
return true;
});
} }
} }

View File

@ -12,7 +12,6 @@ import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -474,23 +473,19 @@ public abstract class JobsDAO {
} }
public final synchronized void setUp() { public final synchronized void setUp() {
CompletableFuture.supplyAsync(() -> { if (getConnection() == null)
if (getConnection() == null) return;
return null;
vacuum(); vacuum();
try { try {
for (DBTables one : DBTables.values()) { for (DBTables one : DBTables.values()) {
createDefaultTable(one); createDefaultTable(one);
}
checkDefaultCollumns();
} finally {
} }
return null; checkDefaultCollumns();
}); } finally {
}
} }
protected abstract void checkUpdate() throws SQLException; protected abstract void checkUpdate() throws SQLException;