Improved DB connection handling

Support for aggressive connection timeouts, with exponential backoff
for multiple failures.
This commit is contained in:
Marco Cunha
2012-10-22 14:45:16 +02:00
parent e29484e14b
commit 34ae64706e
2 changed files with 118 additions and 60 deletions

View File

@ -15,15 +15,12 @@ public class SQLReconnect implements Runnable {
@Override
public void run() {
if (!Database.isConnected()) {
Database.connect();
if (Database.isConnected()) {
Users.saveAll(); //Save all profiles
Users.clearAll(); //Clear the profiles
if (Database.checkConnection()) {
Users.saveAll(); //Save all profiles
Users.clearAll(); //Clear the profiles
for (Player player : plugin.getServer().getOnlinePlayers()) {
Users.addUser(player); //Add in new profiles, forcing them to 'load' again from MySQL
}
for (Player player : plugin.getServer().getOnlinePlayers()) {
Users.addUser(player); //Add in new profiles, forcing them to 'load' again from MySQL
}
}
}