Update 3.3.3

This commit is contained in:
Xephi
2014-02-20 12:54:10 +01:00
parent 5a089fa690
commit 4e7e9e6cb4
21 changed files with 315 additions and 127 deletions
@@ -64,7 +64,6 @@ public class MySQLThread extends Thread implements DataSource {
this.columnEmail = Settings.getMySQLColumnEmail;
this.columnOthers = Settings.getMySQLOtherUsernameColumn;
this.columnID = Settings.getMySQLColumnId;
try {
this.connect();
this.setup();
@@ -635,6 +634,17 @@ public class MySQLThread extends Thread implements DataSource {
@Override
public void reload() {
try {
reconnect(true);
} catch (Exception e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
}
}
private void close(Statement st) {
@@ -780,7 +790,7 @@ public class MySQLThread extends Thread implements DataSource {
} catch (Exception te) {
try {
con = null;
reconnect();
reconnect(false);
} catch (Exception e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
@@ -796,7 +806,7 @@ public class MySQLThread extends Thread implements DataSource {
throw new AssertionError(ae.getMessage());
try {
con = null;
reconnect();
reconnect(false);
} catch (Exception e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
@@ -812,7 +822,7 @@ public class MySQLThread extends Thread implements DataSource {
return con;
}
private synchronized void reconnect() throws ClassNotFoundException, SQLException, TimeoutException {
private synchronized void reconnect(boolean reload) throws ClassNotFoundException, SQLException, TimeoutException {
conPool.dispose();
Class.forName("com.mysql.jdbc.Driver");
MysqlConnectionPoolDataSource dataSource = new MysqlConnectionPoolDataSource();
@@ -822,7 +832,8 @@ public class MySQLThread extends Thread implements DataSource {
dataSource.setUser(username);
dataSource.setPassword(password);
conPool = new MiniConnectionPoolManager(dataSource, 10);
ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!");
if (!reload)
ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!");
}
}