diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index 9c613ec35..9da225b94 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -40,6 +40,7 @@ public class MySQL implements DataSource { private String password; private String database; private String tableName; + private int poolSize; private List columnOthers; private Columns col; private HashAlgorithm hashAlgorithm; @@ -98,6 +99,10 @@ public class MySQL implements DataSource { this.phpBbPrefix = settings.getProperty(HooksSettings.PHPBB_TABLE_PREFIX); this.phpBbGroup = settings.getProperty(HooksSettings.PHPBB_ACTIVATED_GROUP_ID); this.wordpressPrefix = settings.getProperty(HooksSettings.WORDPRESS_TABLE_PREFIX); + this.poolSize = settings.getProperty(DatabaseSettings.MYSQL_POOL_SIZE); + if(poolSize == -1) { + poolSize = RuntimeUtils.getCoreCount(); + } } private void setConnectionArguments() throws RuntimeException { @@ -105,7 +110,7 @@ public class MySQL implements DataSource { ds.setPoolName("AuthMeMYSQLPool"); // Pool size - ds.setMaximumPoolSize(RuntimeUtils.getCoreCount()); + ds.setMaximumPoolSize(poolSize); // Database URL ds.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database); diff --git a/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java b/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java index 2dc769ec6..c82a7a81d 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java @@ -98,6 +98,10 @@ public class DatabaseSettings implements SettingsHolder { public static final Property MYSQL_COL_GROUP = newProperty("ExternalBoardOptions.mySQLColumnGroup", ""); + @Comment("Overrides the size of the DB Connection Pool, -1 = Auto") + public static final Property MYSQL_POOL_SIZE = + newProperty("DataSource.poolSize", -1); + private DatabaseSettings() { } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index bed1d2c43..aba5a8658 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -40,6 +40,8 @@ DataSource: mySQLlastlocWorld: world # Column for RealName mySQLRealName: realname + # Overrides the size of the DB Connection Pool, -1 = Auto + poolSize: -1 settings: sessions: # Do you want to enable the session feature?