Added config setting to bungee & bukkit for custom MySQL launch options #452

This commit is contained in:
Rsl1122 2017-12-06 16:08:14 +02:00
parent 90c448afe5
commit 007ee97699
4 changed files with 12 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package main.java.com.djrapitops.plan.database.databases;
import com.djrapitops.plugin.api.utility.log.Log;
import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
import main.java.com.djrapitops.plan.settings.Settings;
@ -35,8 +36,13 @@ public class MySQLDB extends SQLDB {
String host = Settings.DB_HOST.toString();
String port = Integer.toString(Settings.DB_PORT.getNumber());
String database = Settings.DB_DATABASE.toString();
String launchOptions = Settings.DB_LAUNCH_OPTIONS.toString();
if (launchOptions.isEmpty() || !launchOptions.startsWith("?") || launchOptions.endsWith("&")) {
Log.error("Launch Options were faulty, using default (?rewriteBatchedStatements=true&useSSL=false)");
launchOptions = "?rewriteBatchedStatements=true&useSSL=false";
}
dataSource.setUrl("jdbc:mysql://" + host + ":" + port + "/" + database + "?rewriteBatchedStatements=true&useSSL=false");
dataSource.setUrl("jdbc:mysql://" + host + ":" + port + "/" + database + launchOptions);
String username = Settings.DB_USER.toString();
String password = Settings.DB_PASS.toString();

View File

@ -49,6 +49,7 @@ public enum Settings {
DB_USER("Database.MySQL.User"),
DB_PASS("Database.MySQL.Password"),
DB_DATABASE("Database.MySQL.Database"),
DB_LAUNCH_OPTIONS("Database.MySQL.LaunchOptions"),
LOCALE("Plugin.Locale"),
WEBSERVER_IP("WebServer.InternalIP"),
ANALYSIS_EXPORT_PATH("Analysis.Export.DestinationFolder"),

View File

@ -34,6 +34,8 @@ Database:
User: root
Password: minecraft
Database: Plan
# Launch options to append after driver address, for example
LaunchOptions: "?rewriteBatchedStatements=true&useSSL=false"
# -----------------------------------------------------
Commands:
AlternativeIP:

View File

@ -48,6 +48,8 @@ Database:
User: root
Password: minecraft
Database: Plan
# Launch options to append after driver address, for example
LaunchOptions: "?rewriteBatchedStatements=true&useSSL=false"
# -----------------------------------------------------
Commands:
AlternativeIP: