Skip to content

Commit bd88b29

Browse files
committed
Remove the user & password settings for database, as they should be added to the jdbc-connection string
1 parent 89ca705 commit bd88b29

File tree

4 files changed

+21
-49
lines changed

4 files changed

+21
-49
lines changed

BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/SQLConfig.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ public class SQLConfig extends StorageConfig implements SQLStorageSettings {
4040

4141
@DebugDump private String driverJar = null;
4242
@DebugDump private String driverClass = null;
43-
@DebugDump private String dbUrl = "jdbc:mysql://localhost:3306/bluemap";
44-
@DebugDump private String user = "root";
45-
private String password = "";
43+
private String connectionUrl = "jdbc:mysql://localhost/bluemap?permitMysqlScheme";
4644

4745
@DebugDump private Compression compression = Compression.GZIP;
4846

@@ -65,18 +63,8 @@ public Optional<String> getDriverClass() {
6563
}
6664

6765
@Override
68-
public String getDbUrl() {
69-
return dbUrl;
70-
}
71-
72-
@Override
73-
public String getUser() {
74-
return user;
75-
}
76-
77-
@Override
78-
public String getPassword() {
79-
return password;
66+
public String getConnectionUrl() {
67+
return connectionUrl;
8068
}
8169

8270
@Override

BlueMapCommon/src/main/resources/de/bluecolored/bluemap/config/storages/sql.conf

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,17 @@
99
storage-type: SQL
1010

1111
# The JDBC-Connection URL that is used to connect to the database.
12-
# The format for this url is: jdbc:[driver]://[host]:[port]/[database]
13-
db-url: "jdbc:mysql://localhost:3306/bluemap"
14-
15-
# The user that is used to connect to the database
16-
user: "root"
17-
18-
# The password that is used to connect to the database
19-
# (If this is empty, no password is used to connect to the database)
20-
password: ""
12+
# The format for this url is usually something like: jdbc:[driver]://[host]:[port]/[database]?user=[user]&password=[password]
13+
# The exact format of the url is determined by the JDBC-Driver you are using.
14+
db-connection-url: "jdbc:mysql://localhost/bluemap?permitMysqlScheme"
15+
#db-connection-url: "jdbc:mariadb://localhost/bluemap?user=root"
16+
#db-connection-url: "jdbc:mysql://localhost:3306/bluemap?user=root&password=password"
2117

2218
# This can be used to load a custom jdbc-driver from a .jar file.
2319
# E.g. if your runtime-environment is not already providing the sql-driver you need,
2420
# you could download the MariaDB JDBC-Connector from https://mariadb.com/downloads/connectors/connectors-data-access/java8-connector/
2521
# place it in the './bluemap' folder and use is like this:
26-
#driver-jar: "bluemap/mariadb-java-client-2.7.4.jar"
22+
#driver-jar: "bluemap/mariadb-java-client-3.0.7.jar"
2723

2824
# This is the driver-class that bluemap will try to load and use.
2925
# Check the documentation of the driver you are using if you don't know this.

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/storage/sql/SQLStorage.java

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ public SQLStorage(SQLStorageSettings config) throws MalformedURLException, SQLDr
8181
"Instead you'll need to add your driver-jar to the classpath when starting your server," +
8282
"e.g. using the '-classpath' command-line argument", ex);*/
8383
}
84-
this.dataSource = createDataSource(config.getDbUrl(), config.getUser(), config.getPassword(), driver);
84+
this.dataSource = createDataSource(config.getConnectionUrl(), driver);
8585
} else {
8686
Class.forName(config.getDriverClass().get());
87-
this.dataSource = createDataSource(config.getDbUrl(), config.getUser(), config.getPassword());
87+
this.dataSource = createDataSource(config.getConnectionUrl());
8888
}
8989
} else {
90-
this.dataSource = createDataSource(config.getDbUrl(), config.getUser(), config.getPassword());
90+
this.dataSource = createDataSource(config.getConnectionUrl());
9191
}
9292
} catch (ClassNotFoundException ex) {
9393
throw new SQLDriverException("The driver-class does not exist.", ex);
@@ -98,8 +98,8 @@ public SQLStorage(SQLStorageSettings config) throws MalformedURLException, SQLDr
9898
this.hiresCompression = config.getCompression();
9999
}
100100

101-
public SQLStorage(String dbUrl, String user, String password, Compression compression) {
102-
this.dataSource = createDataSource(dbUrl, user, password);
101+
public SQLStorage(String dbUrl, Compression compression) {
102+
this.dataSource = createDataSource(dbUrl);
103103
this.hiresCompression = compression;
104104
}
105105

@@ -621,25 +621,17 @@ private int lookupFK(String table, String idField, String valueField, String val
621621
}, 2);
622622
}
623623

624-
private DataSource createDataSource(String dbUrl, String user, String password) {
625-
ConnectionFactory connectionFactory = new DriverManagerConnectionFactory(
626-
dbUrl,
627-
user,
628-
password
629-
);
630-
631-
return createDataSource(connectionFactory);
624+
private DataSource createDataSource(String dbUrl) {
625+
Logger.global.logInfo("Creating datasource for: " + dbUrl);
626+
return createDataSource(new DriverManagerConnectionFactory(dbUrl));
632627
}
633628

634-
private DataSource createDataSource(String dbUrl, String user, String password, Driver driver) {
635-
Properties properties = new Properties();
636-
properties.put("user", user);
637-
properties.put("password", password);
638-
629+
private DataSource createDataSource(String dbUrl, Driver driver) {
630+
Logger.global.logInfo("Creating driver-datasource for: " + dbUrl);
639631
ConnectionFactory connectionFactory = new DriverConnectionFactory(
640632
driver,
641633
dbUrl,
642-
properties
634+
new Properties()
643635
);
644636

645637
return createDataSource(connectionFactory);

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/storage/sql/SQLStorageSettings.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ public interface SQLStorageSettings {
1212

1313
Optional<String> getDriverClass();
1414

15-
String getDbUrl();
16-
17-
String getUser();
18-
19-
String getPassword();
15+
String getConnectionUrl();
2016

2117
Compression getCompression();
2218

0 commit comments

Comments
 (0)