Set default port

This commit is contained in:
Luck 2016-12-18 10:16:05 +00:00
parent 4857969ca4
commit b4b661a3ad
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -54,17 +54,21 @@ public class MySQLBacking extends SQLBacking {
public void init() { public void init() {
HikariConfig config = new HikariConfig(); HikariConfig config = new HikariConfig();
final String address = configuration.getAddress(); String address = configuration.getAddress();
final String database = configuration.getDatabase(); String[] addressSplit = address.split(":");
final String username = configuration.getUsername(); address = addressSplit[0];
final String password = configuration.getPassword(); String port = addressSplit.length > 1 ? addressSplit[1] : "3306";
String database = configuration.getDatabase();
String username = configuration.getUsername();
String password = configuration.getPassword();
config.setMaximumPoolSize(configuration.getPoolSize()); config.setMaximumPoolSize(configuration.getPoolSize());
config.setPoolName("luckperms"); config.setPoolName("luckperms");
config.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource"); config.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
config.addDataSourceProperty("serverName", address.split(":")[0]); config.addDataSourceProperty("serverName", address);
config.addDataSourceProperty("port", address.split(":")[1]); config.addDataSourceProperty("port", port);
config.addDataSourceProperty("databaseName", database); config.addDataSourceProperty("databaseName", database);
config.addDataSourceProperty("user", username); config.addDataSourceProperty("user", username);
config.addDataSourceProperty("password", password); config.addDataSourceProperty("password", password);