diff --git a/Core/src/main/java/com/intellectualcrafters/plot/config/Storage.java b/Core/src/main/java/com/intellectualcrafters/plot/config/Storage.java index be4e62b1f..2a85d7356 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/config/Storage.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/config/Storage.java @@ -1,6 +1,9 @@ package com.intellectualcrafters.plot.config; import java.io.File; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; public class Storage extends Config { @@ -23,6 +26,9 @@ public class Storage extends Config { public static String USER = "root"; public static String PASSWORD = "password"; public static String DATABASE = "plot_db"; + + @Comment("Set additional properties: https://goo.gl/wngtN8") + public static List PROPERTIES = new ArrayList<>(Collections.singletonList("useSSL=false")); } @Comment("SQLite section") diff --git a/Core/src/main/java/com/intellectualcrafters/plot/database/MySQL.java b/Core/src/main/java/com/intellectualcrafters/plot/database/MySQL.java index 4a1256c25..153de8030 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/database/MySQL.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/database/MySQL.java @@ -1,7 +1,7 @@ package com.intellectualcrafters.plot.database; -import com.intellectualcrafters.plot.PS; - +import com.intellectualcrafters.plot.config.Storage; +import com.intellectualcrafters.plot.util.StringMan; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; @@ -45,7 +45,7 @@ public class MySQL extends Database { public Connection forceConnection() throws SQLException, ClassNotFoundException { Class.forName("com.mysql.jdbc.Driver"); this.connection = - DriverManager.getConnection("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database + "?useSSL=false", this.user, this.password); + DriverManager.getConnection("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database + "?" + StringMan.join(Storage.MySQL.PROPERTIES, "&"), this.user, this.password); return this.connection; } @@ -54,11 +54,7 @@ public class MySQL extends Database { if (checkConnection()) { return this.connection; } - Class.forName("com.mysql.jdbc.Driver"); - PS.debug("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database + "?useSSL=false"); - this.connection = - DriverManager.getConnection("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database + "?useSSL=false", this.user, this.password); - return this.connection; + return forceConnection(); } @Override