diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsConnectionPool.java b/src/main/java/com/gamingmesh/jobs/dao/JobsConnectionPool.java index 6958de42..cdcb48dd 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsConnectionPool.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsConnectionPool.java @@ -2,7 +2,6 @@ package com.gamingmesh.jobs.dao; import java.sql.DriverManager; import java.sql.SQLException; -import java.util.concurrent.CompletableFuture; public class JobsConnectionPool { @@ -25,31 +24,23 @@ public class JobsConnectionPool { connection = null; } - CompletableFuture.supplyAsync(() -> { - if (connection == null) { - try { - connection = new JobsConnection(DriverManager.getConnection(url, username, password)); - } catch (SQLException e) { - } + if (connection == null) { + try { + connection = new JobsConnection(DriverManager.getConnection(url, username, password)); + } catch (SQLException e) { } - - return true; - }); + } return connection; } - public void closeConnection() { - CompletableFuture.supplyAsync(() -> { - if (connection != null) { - try { - connection.closeConnection(); - } catch (SQLException e) { - e.printStackTrace(); - } + public synchronized void closeConnection() { + if (connection != null) { + try { + connection.closeConnection(); + } catch (SQLException e) { + e.printStackTrace(); } - - return true; - }); + } } } diff --git a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java index b7290a1a..08af05c3 100644 --- a/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java +++ b/src/main/java/com/gamingmesh/jobs/dao/JobsDAO.java @@ -12,7 +12,6 @@ import java.util.List; import java.util.Map.Entry; import java.util.Set; import java.util.UUID; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Bukkit; @@ -474,23 +473,19 @@ public abstract class JobsDAO { } public final synchronized void setUp() { - CompletableFuture.supplyAsync(() -> { - if (getConnection() == null) - return null; + if (getConnection() == null) + return; - vacuum(); + vacuum(); - try { - for (DBTables one : DBTables.values()) { - createDefaultTable(one); - } - - checkDefaultCollumns(); - } finally { + try { + for (DBTables one : DBTables.values()) { + createDefaultTable(one); } - return null; - }); + checkDefaultCollumns(); + } finally { + } } protected abstract void checkUpdate() throws SQLException;