mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +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();
|
boolean hasTask = !globalTasks.isEmpty() || !playerTasks.isEmpty() || !plotTasks.isEmpty() || !clusterTasks.isEmpty();
|
||||||
if (hasTask) {
|
if (hasTask) {
|
||||||
try {
|
try {
|
||||||
if (SQLManager.this.mySQL && System.currentTimeMillis() - last > 550000 || !connection.isValid(10000)) {
|
if (SQLManager.this.mySQL && System.currentTimeMillis() - last > 550000 || !isValid()) {
|
||||||
last = System.currentTimeMillis();
|
last = System.currentTimeMillis();
|
||||||
reconnect();
|
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() {
|
public void reconnect() {
|
||||||
try {
|
try {
|
||||||
close();
|
close();
|
||||||
|
Loading…
Reference in New Issue
Block a user