diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/SQLConfig.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/SQLConfig.java index e51c017e..3088d821 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/SQLConfig.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/SQLConfig.java @@ -40,9 +40,7 @@ public class SQLConfig extends StorageConfig implements SQLStorageSettings { @DebugDump private String driverJar = null; @DebugDump private String driverClass = null; - @DebugDump private String dbUrl = "jdbc:mysql://localhost:3306/bluemap"; - @DebugDump private String user = "root"; - private String password = ""; + private String connectionUrl = "jdbc:mysql://localhost/bluemap?permitMysqlScheme"; @DebugDump private Compression compression = Compression.GZIP; @@ -65,18 +63,8 @@ public Optional getDriverClass() { } @Override - public String getDbUrl() { - return dbUrl; - } - - @Override - public String getUser() { - return user; - } - - @Override - public String getPassword() { - return password; + public String getConnectionUrl() { + return connectionUrl; } @Override diff --git a/BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/storages/sql.conf b/BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/storages/sql.conf index f06fa3c4..28a763c7 100644 --- a/BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/storages/sql.conf +++ b/BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/storages/sql.conf @@ -9,21 +9,17 @@ storage-type: SQL # The JDBC-Connection URL that is used to connect to the database. -# The format for this url is: jdbc:[driver]://[host]:[port]/[database] -db-url: "jdbc:mysql://localhost:3306/bluemap" - -# The user that is used to connect to the database -user: "root" - -# The password that is used to connect to the database -# (If this is empty, no password is used to connect to the database) -password: "" +# The format for this url is usually something like: jdbc:[driver]://[host]:[port]/[database]?user=[user]&password=[password] +# The exact format of the url is determined by the JDBC-Driver you are using. +db-connection-url: "jdbc:mysql://localhost/bluemap?permitMysqlScheme" +#db-connection-url: "jdbc:mariadb://localhost/bluemap?user=root" +#db-connection-url: "jdbc:mysql://localhost:3306/bluemap?user=root&password=password" # This can be used to load a custom jdbc-driver from a .jar file. # E.g. if your runtime-environment is not already providing the sql-driver you need, # you could download the MariaDB JDBC-Connector from https://mariadb.com/downloads/connectors/connectors-data-access/java8-connector/ # place it in the './bluemap' folder and use is like this: -#driver-jar: "bluemap/mariadb-java-client-2.7.4.jar" +#driver-jar: "bluemap/mariadb-java-client-3.0.7.jar" # This is the driver-class that bluemap will try to load and use. # Check the documentation of the driver you are using if you don't know this. diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/storage/sql/SQLStorage.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/storage/sql/SQLStorage.java index c3f873ef..b1a40a73 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/storage/sql/SQLStorage.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/storage/sql/SQLStorage.java @@ -81,13 +81,13 @@ public SQLStorage(SQLStorageSettings config) throws MalformedURLException, SQLDr "Instead you'll need to add your driver-jar to the classpath when starting your server," + "e.g. using the '-classpath' command-line argument", ex);*/ } - this.dataSource = createDataSource(config.getDbUrl(), config.getUser(), config.getPassword(), driver); + this.dataSource = createDataSource(config.getConnectionUrl(), driver); } else { Class.forName(config.getDriverClass().get()); - this.dataSource = createDataSource(config.getDbUrl(), config.getUser(), config.getPassword()); + this.dataSource = createDataSource(config.getConnectionUrl()); } } else { - this.dataSource = createDataSource(config.getDbUrl(), config.getUser(), config.getPassword()); + this.dataSource = createDataSource(config.getConnectionUrl()); } } catch (ClassNotFoundException ex) { throw new SQLDriverException("The driver-class does not exist.", ex); @@ -98,8 +98,8 @@ public SQLStorage(SQLStorageSettings config) throws MalformedURLException, SQLDr this.hiresCompression = config.getCompression(); } - public SQLStorage(String dbUrl, String user, String password, Compression compression) { - this.dataSource = createDataSource(dbUrl, user, password); + public SQLStorage(String dbUrl, Compression compression) { + this.dataSource = createDataSource(dbUrl); this.hiresCompression = compression; } @@ -621,25 +621,17 @@ private int lookupFK(String table, String idField, String valueField, String val }, 2); } - private DataSource createDataSource(String dbUrl, String user, String password) { - ConnectionFactory connectionFactory = new DriverManagerConnectionFactory( - dbUrl, - user, - password - ); - - return createDataSource(connectionFactory); + private DataSource createDataSource(String dbUrl) { + Logger.global.logInfo("Creating datasource for: " + dbUrl); + return createDataSource(new DriverManagerConnectionFactory(dbUrl)); } - private DataSource createDataSource(String dbUrl, String user, String password, Driver driver) { - Properties properties = new Properties(); - properties.put("user", user); - properties.put("password", password); - + private DataSource createDataSource(String dbUrl, Driver driver) { + Logger.global.logInfo("Creating driver-datasource for: " + dbUrl); ConnectionFactory connectionFactory = new DriverConnectionFactory( driver, dbUrl, - properties + new Properties() ); return createDataSource(connectionFactory); diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/storage/sql/SQLStorageSettings.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/storage/sql/SQLStorageSettings.java index 89c7f412..283545ef 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/storage/sql/SQLStorageSettings.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/storage/sql/SQLStorageSettings.java @@ -12,11 +12,7 @@ public interface SQLStorageSettings { Optional getDriverClass(); - String getDbUrl(); - - String getUser(); - - String getPassword(); + String getConnectionUrl(); Compression getCompression();