diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 4147af89c..1bade8a2a 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -313,6 +313,8 @@ public class Config extends AutoUpdateConfigLoader { public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); } public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); } public String getMySQLUserPassword() { return getStringIncludingInts("MySQL.Database.User_Password"); } + public int getMySQLMaxConnections() { return config.getInt("MySQL.Database.MaxConnections"); } + public int getMySQLMaxPoolSize() { return config.getInt("MySQL.Database.MaxPoolSize"); } private String getStringIncludingInts(String key) { String str = config.getString(key); diff --git a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java index ae90578ee..d1b3261d6 100644 --- a/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java @@ -52,8 +52,8 @@ public final class SQLDatabaseManager implements DatabaseManager { connectionProperties.put("autoReconnect", "false"); connectionPool = new ConnectionPool("mcMMO-Pool", 1 /*Minimum of one*/, - 10 /*max pool size */, // TODO Configurable? - 10 /*max num connections*/, // TODO Configurable? + Config.getInstance().getMySQLMaxPoolSize() /*max pool size */, + Config.getInstance().getMySQLMaxConnections() /*max num connections*/, 0 /* idle timeout of connections */, connectionString, connectionProperties); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 4b0826838..5fb25cd49 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -122,6 +122,12 @@ MySQL: User_Password: UserPassword Name: DataBaseName TablePrefix: mcmmo_ + # This setting is the max simultaneous mysql connections allowed at a time, needs to be + # high enough to support multiple player logins in quick succession + MaxConnections: 30 + # This setting is the max size of the pool of cached connections that we hold available + # at any given time + MaxPoolSize: 20 Server: Port: 3306 Address: localhost