This commit is contained in:
Gabriele C 2015-08-22 16:34:06 +02:00
parent c12e24d0f8
commit 217c217d13
3 changed files with 17 additions and 7 deletions

View File

@ -180,7 +180,7 @@
<dependency> <dependency>
<groupId>com.zaxxer</groupId> <groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId> <artifactId>HikariCP</artifactId>
<version>2.4.0</version> <version>2.4.1</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>

View File

@ -505,9 +505,11 @@ public class FileCache {
else armours[i] = item; else armours[i] = item;
} }
} catch (final RuntimeException e) { } catch (final RuntimeException e) {
//verbose
e.printStackTrace(); e.printStackTrace();
ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming..."); ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming...");
} catch (final Exception e) { } catch (final Exception e) {
//verbose
e.printStackTrace(); e.printStackTrace();
ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming..."); ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming...");
} finally { } finally {
@ -517,10 +519,12 @@ public class FileCache {
return new DataFileCache(inv, armours, group, op, flying); return new DataFileCache(inv, armours, group, op, flying);
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {
// Verbose
e.printStackTrace(); e.printStackTrace();
ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming..."); ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming...");
return null; return null;
} catch (Exception e) { } catch (Exception e) {
// Verbose
e.printStackTrace(); e.printStackTrace();
ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming..."); ConsoleLogger.showError("Error while reading file for " + player.getName() + ", some wipe inventory incoming...");
return null; return null;

View File

@ -113,16 +113,19 @@ public class MySQL implements DataSource {
throws ClassNotFoundException, SQLException, TimeoutException, throws ClassNotFoundException, SQLException, TimeoutException,
NumberFormatException, PoolInitializationException { NumberFormatException, PoolInitializationException {
HikariConfig config = new HikariConfig(); 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.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database);
config.setUsername(this.username); config.setUsername(this.username);
config.setPassword(this.password); config.setPassword(this.password);
config.setPoolName("AuthMeMYSQLPool");
config.addDataSourceProperty("cachePrepStmts", "true"); config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250"); config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
config.addDataSourceProperty("autoReconnect", true); config.addDataSourceProperty("autoReconnect", true);
config.setMaxLifetime(12000); config.setInitializationFailFast(true); // Don't start the plugin if the database is unavariable
config.setInitializationFailFast(false); config.setMaxLifetime(12000); // 12 Sec
config.setIdleTimeout(120000); // 2 Min
config.setMaximumPoolSize(50); // 50 Connections (including idle connections)
ds = new HikariDataSource(config); ds = new HikariDataSource(config);
ConsoleLogger.info("Connection pool ready"); ConsoleLogger.info("Connection pool ready");
} }
@ -907,6 +910,8 @@ public class MySQL implements DataSource {
if (ds != null) if (ds != null)
ds.close(); ds.close();
HikariConfig config = new HikariConfig(); 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.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database);
config.setUsername(this.username); config.setUsername(this.username);
config.setPassword(this.password); config.setPassword(this.password);
@ -914,9 +919,10 @@ public class MySQL implements DataSource {
config.addDataSourceProperty("prepStmtCacheSize", "250"); config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
config.addDataSourceProperty("autoReconnect", true); config.addDataSourceProperty("autoReconnect", true);
config.setInitializationFailFast(false); config.setInitializationFailFast(true); // Don't start the plugin if the database is unavariable
config.setMaxLifetime(12000); config.setMaxLifetime(12000); // 12 Sec
config.setPoolName("AuthMeMYSQLPool"); config.setIdleTimeout(120000); // 2 Min
config.setMaximumPoolSize(50); // 50 Connections (including idle connections)
ds = new HikariDataSource(config); ds = new HikariDataSource(config);
if (!reload) if (!reload)
ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!"); ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!");