This commit is contained in:
Jesse Boyd 2017-10-31 23:26:08 +11:00
parent 097159d606
commit 7e2a911530
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
2 changed files with 10 additions and 8 deletions

View File

@ -1,6 +1,9 @@
package com.intellectualcrafters.plot.config; package com.intellectualcrafters.plot.config;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Storage extends Config { public class Storage extends Config {
@ -23,6 +26,9 @@ public class Storage extends Config {
public static String USER = "root"; public static String USER = "root";
public static String PASSWORD = "password"; public static String PASSWORD = "password";
public static String DATABASE = "plot_db"; public static String DATABASE = "plot_db";
@Comment("Set additional properties: https://goo.gl/wngtN8")
public static List<String> PROPERTIES = new ArrayList<>(Collections.singletonList("useSSL=false"));
} }
@Comment("SQLite section") @Comment("SQLite section")

View File

@ -1,7 +1,7 @@
package com.intellectualcrafters.plot.database; 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.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -45,7 +45,7 @@ public class MySQL extends Database {
public Connection forceConnection() throws SQLException, ClassNotFoundException { public Connection forceConnection() throws SQLException, ClassNotFoundException {
Class.forName("com.mysql.jdbc.Driver"); Class.forName("com.mysql.jdbc.Driver");
this.connection = 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; return this.connection;
} }
@ -54,11 +54,7 @@ public class MySQL extends Database {
if (checkConnection()) { if (checkConnection()) {
return this.connection; return this.connection;
} }
Class.forName("com.mysql.jdbc.Driver"); return forceConnection();
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;
} }
@Override @Override