mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
DB fix
This commit is contained in:
parent
9fd53af483
commit
8ebf71c87f
@ -135,7 +135,7 @@ public class SQLManager implements AbstractDB {
|
||||
boolean hasTask = !globalTasks.isEmpty() || !playerTasks.isEmpty() || !plotTasks.isEmpty() || !clusterTasks.isEmpty();
|
||||
if (hasTask) {
|
||||
try {
|
||||
if (SQLManager.this.mySQL && System.currentTimeMillis() - last > 550000 || !connection.isValid(10000)) {
|
||||
if (SQLManager.this.mySQL && System.currentTimeMillis() - last > 550000 || !isValid()) {
|
||||
last = System.currentTimeMillis();
|
||||
reconnect();
|
||||
}
|
||||
@ -167,6 +167,15 @@ public class SQLManager implements AbstractDB {
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
try (PreparedStatement stmt = this.connection.prepareStatement("SELECT 1")) {
|
||||
stmt.executeQuery();
|
||||
return true;
|
||||
} catch (Throwable e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void reconnect() {
|
||||
try {
|
||||
close();
|
||||
|
Loading…
Reference in New Issue
Block a user