1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-08 01:08:23 +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,7 +24,6 @@ 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));
@ -33,14 +31,10 @@ public class JobsConnectionPool {
} }
} }
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();
@ -48,8 +42,5 @@ public class JobsConnectionPool {
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,9 +473,8 @@ public abstract class JobsDAO {
} }
public final synchronized void setUp() { public final synchronized void setUp() {
CompletableFuture.supplyAsync(() -> {
if (getConnection() == null) if (getConnection() == null)
return null; return;
vacuum(); vacuum();
@ -488,9 +486,6 @@ public abstract class JobsDAO {
checkDefaultCollumns(); checkDefaultCollumns();
} finally { } finally {
} }
return null;
});
} }
protected abstract void checkUpdate() throws SQLException; protected abstract void checkUpdate() throws SQLException;