Skip to content

Commit

Permalink
Make MySQL maximumPoolSize configurable (#411)
Browse files Browse the repository at this point in the history
* Make MySQL maximumPoolSize configurable

* Correctly assign default value to mysql-maximum-pool-size

---------

Co-authored-by: Intelli <[email protected]>
  • Loading branch information
C0Nd3Mnd and Intelli authored Jul 17, 2023
1 parent 342fadd commit 6045799
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/net/coreprotect/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public class Config extends Language {
public boolean PLAYER_SESSIONS;
public boolean USERNAME_CHANGES;
public boolean WORLDEDIT;
public int MYSQL_MAXIMUM_POOL_SIZE;
public int MYSQL_PORT;
public int DEFAULT_RADIUS;
public int MAX_RADIUS;
Expand Down Expand Up @@ -203,6 +204,7 @@ private void readValues() {
this.MYSQL_DATABASE = this.getString("mysql-database");
this.MYSQL_USERNAME = this.getString("mysql-username");
this.MYSQL_PASSWORD = this.getString("mysql-password");
this.MYSQL_MAXIMUM_POOL_SIZE = this.getInt("mysql-maximum-pool-size", 10);
this.LANGUAGE = this.getString("language");
this.CHECK_UPDATES = this.getBoolean("check-updates");
this.API_ENABLED = this.getBoolean("api-enabled");
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/net/coreprotect/config/ConfigHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class ConfigHandler extends Queue {
public static String username = "root";
public static String password = "";
public static String prefix = "co_";
public static int maximumPoolSize = 10;

public static HikariDataSource hikariDataSource = null;
public static final boolean isSpigot = Util.isSpigot();
public static final boolean isPaper = Util.isPaper();
Expand Down Expand Up @@ -174,6 +176,7 @@ private static void loadConfig() {
ConfigHandler.database = Config.getGlobal().MYSQL_DATABASE;
ConfigHandler.username = Config.getGlobal().MYSQL_USERNAME;
ConfigHandler.password = Config.getGlobal().MYSQL_PASSWORD;
ConfigHandler.maximumPoolSize = Config.getGlobal().MYSQL_MAXIMUM_POOL_SIZE;
ConfigHandler.prefix = Config.getGlobal().PREFIX;

ConfigHandler.loadBlacklist(); // Load the blacklist file if it exists.
Expand Down Expand Up @@ -230,6 +233,7 @@ public static void loadDatabase() {
config.setJdbcUrl("jdbc:mysql://" + ConfigHandler.host + ":" + ConfigHandler.port + "/" + ConfigHandler.database);
config.setUsername(ConfigHandler.username);
config.setPassword(ConfigHandler.password);
config.setMaximumPoolSize(ConfigHandler.maximumPoolSize);
config.setMaxLifetime(60000);
config.addDataSourceProperty("characterEncoding", "UTF-8");
config.addDataSourceProperty("connectionTimeout", "10000");
Expand Down

0 comments on commit 6045799

Please sign in to comment.