diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index 694c2fc8d..a85e2435a 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -109,26 +109,28 @@ public class MySQL implements DataSource { private synchronized void setConnectionArguments() throws RuntimeException { ds = new HikariDataSource(); ds.setPoolName("AuthMeMYSQLPool"); - ds.setDriverClassName("com.mysql.jdbc.Driver"); - ds.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database); - ds.addDataSourceProperty("rewriteBatchedStatements", "true"); - ds.addDataSourceProperty("jdbcCompliantTruncation", "false"); - ds.addDataSourceProperty("cachePrepStmts", "true"); - ds.addDataSourceProperty("prepStmtCacheSize", "250"); - ds.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); - //set utf-8 as default encoding + // Database URL + ds.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database); + + // Auth + ds.setUsername(this.username); + ds.setPassword(this.password); + + // Encoding ds.addDataSourceProperty("characterEncoding", "utf8"); ds.addDataSourceProperty("encoding","UTF-8"); ds.addDataSourceProperty("useUnicode", "true"); - ds.setUsername(this.username); - ds.setPassword(this.password); - ds.setInitializationFailFast(true); // Don't start the plugin if the database is unavailable - ds.setMaxLifetime(180000); // 3 Min - ds.setIdleTimeout(60000); // 1 Min - ds.setMinimumIdle(2); - ds.setMaximumPoolSize((Runtime.getRuntime().availableProcessors() * 2) + 1); + // Random stuff + ds.addDataSourceProperty("rewriteBatchedStatements", "true"); + ds.addDataSourceProperty("jdbcCompliantTruncation", "false"); + + // Caching + ds.addDataSourceProperty("cachePrepStmts", "true"); + ds.addDataSourceProperty("prepStmtCacheSize", "250"); + ds.addDataSourceProperty("prepStmtCacheSqlLimit", "2048"); + ConsoleLogger.info("Connection arguments loaded, Hikari ConnectionPool ready!"); } diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index ca15b12fb..b2f2d0c3f 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -161,7 +161,7 @@ public class AuthMePlayerListener implements Listener { final Player player = event.getPlayer(); if (shouldCancelEvent(player)) { event.setCancelled(true); - // TODO: a spambot calls this too often, too may threads checking if auth is available. + // TODO: a spambot calls this too often, too many threads checking if auth is available. // Possible solution: add a cooldown. // sendLoginOrRegisterMessage(player); } else if (settings.getProperty(RestrictionSettings.HIDE_CHAT)) {