MySQL table prefix and connection pool size settings

This commit is contained in:
Esophose 2020-03-16 16:13:59 -06:00
parent 08405801b6
commit 3bf5f899bd
3 changed files with 5 additions and 2 deletions

View file

@ -2,6 +2,7 @@ package dev.esophose.playerparticles.database;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import dev.esophose.playerparticles.manager.ConfigurationManager.Setting;
import java.sql.Connection;
import java.sql.SQLException;
import org.bukkit.plugin.Plugin;
@ -19,7 +20,7 @@ public class MySQLConnector implements DatabaseConnector {
config.setJdbcUrl("jdbc:mysql://" + hostname + ":" + port + "/" + database + "?useSSL=" + useSSL);
config.setUsername(username);
config.setPassword(password);
config.setMaximumPoolSize(5);
config.setMaximumPoolSize(Setting.MYSQL_CONNECTION_POOL_SIZE.getInt());
try {
this.hikari = new HikariDataSource(config);

View file

@ -63,7 +63,9 @@ public class ConfigurationManager extends Manager {
MYSQL_DATABASE_NAME("mysql-settings.database-name", "", "MySQL Database Name"),
MYSQL_USER_NAME("mysql-settings.user-name", "", "MySQL Database User Name"),
MYSQL_USER_PASSWORD("mysql-settings.user-password", "", "MySQL Database User Password"),
MYSQL_TABLE_PREFIX("mysql-settings.table-prefix", PlayerParticles.getInstance().getDescription().getName().toLowerCase() + "_", "The prefix of the tables in the database", "Do not change this after tables have already been created or you will have data loss"),
MYSQL_USE_SSL("mysql-settings.use-ssl", false, "If the database connection should use SSL", "You should enable this if your database supports SSL"),
MYSQL_CONNECTION_POOL_SIZE("mysql-settings.connection-pool-size", 5, "The size of the connection pool to the database", "Not recommended to go below 2 or above 5"),
GUI_ICON("gui-icon", null,
"This configuration option allows you to change any of the GUI",

View file

@ -547,7 +547,7 @@ public class DataManager extends Manager {
* @return the prefix to be used by all table names
*/
public String getTablePrefix() {
return this.playerParticles.getDescription().getName().toLowerCase() + '_';
return Setting.MYSQL_TABLE_PREFIX.getString();
}
}