From 217c217d13031f56f3ada74fcc508de4bcbd0ab3 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sat, 22 Aug 2015 16:34:06 +0200 Subject: [PATCH] Stuff --- pom.xml | 2 +- .../xephi/authme/cache/backup/FileCache.java | 4 ++++ .../java/fr/xephi/authme/datasource/MySQL.java | 18 ++++++++++++------ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 2eab1959..c5f2e8f6 100644 --- a/pom.xml +++ b/pom.xml @@ -180,7 +180,7 @@ com.zaxxer HikariCP - 2.4.0 + 2.4.1 compile diff --git a/src/main/java/fr/xephi/authme/cache/backup/FileCache.java b/src/main/java/fr/xephi/authme/cache/backup/FileCache.java index 08eecab9..f06b63f0 100644 --- a/src/main/java/fr/xephi/authme/cache/backup/FileCache.java +++ b/src/main/java/fr/xephi/authme/cache/backup/FileCache.java @@ -505,9 +505,11 @@ public class FileCache { else armours[i] = item; } } catch (final RuntimeException e) { + //verbose e.printStackTrace(); ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming..."); } catch (final Exception e) { + //verbose e.printStackTrace(); ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming..."); } finally { @@ -517,10 +519,12 @@ public class FileCache { return new DataFileCache(inv, armours, group, op, flying); } } catch (RuntimeException e) { + // Verbose e.printStackTrace(); ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming..."); return null; } catch (Exception e) { + // Verbose e.printStackTrace(); ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming..."); return null; diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index 45c9c651..b6cfd5a6 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -113,16 +113,19 @@ public class MySQL implements DataSource { throws ClassNotFoundException, SQLException, TimeoutException, NumberFormatException, PoolInitializationException { HikariConfig config = new HikariConfig(); + config.setPoolName("AuthMeMYSQLPool"); + config.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource"); config.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database); config.setUsername(this.username); config.setPassword(this.password); - config.setPoolName("AuthMeMYSQLPool"); config.addDataSourceProperty("cachePrepStmts", "true"); config.addDataSourceProperty("prepStmtCacheSize", "250"); config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); config.addDataSourceProperty("autoReconnect", true); - config.setMaxLifetime(12000); - config.setInitializationFailFast(false); + config.setInitializationFailFast(true); // Don't start the plugin if the database is unavariable + config.setMaxLifetime(12000); // 12 Sec + config.setIdleTimeout(120000); // 2 Min + config.setMaximumPoolSize(50); // 50 Connections (including idle connections) ds = new HikariDataSource(config); ConsoleLogger.info("Connection pool ready"); } @@ -907,6 +910,8 @@ public class MySQL implements DataSource { if (ds != null) ds.close(); HikariConfig config = new HikariConfig(); + config.setPoolName("AuthMeMYSQLPool"); + config.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource"); config.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database); config.setUsername(this.username); config.setPassword(this.password); @@ -914,9 +919,10 @@ public class MySQL implements DataSource { config.addDataSourceProperty("prepStmtCacheSize", "250"); config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); config.addDataSourceProperty("autoReconnect", true); - config.setInitializationFailFast(false); - config.setMaxLifetime(12000); - config.setPoolName("AuthMeMYSQLPool"); + config.setInitializationFailFast(true); // Don't start the plugin if the database is unavariable + config.setMaxLifetime(12000); // 12 Sec + config.setIdleTimeout(120000); // 2 Min + config.setMaximumPoolSize(50); // 50 Connections (including idle connections) ds = new HikariDataSource(config); if (!reload) ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!");