1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-04 23:37:49 +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.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;
});
}
}
}

View File

@ -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;