mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-30 02:37:34 +02:00
Use mariadb protocol if using its connector
MariaDB enforces this to ensure the selection of the correct driver. Fixes #724
This commit is contained in:
@ -231,7 +231,7 @@ public class FastLoginCore<P extends C, C, T extends PlatformPlugin<C>> {
|
|||||||
|
|
||||||
databaseConfig.setUsername(config.get("username", ""));
|
databaseConfig.setUsername(config.get("username", ""));
|
||||||
databaseConfig.setPassword(config.getString("password"));
|
databaseConfig.setPassword(config.getString("password"));
|
||||||
storage = new MySQLStorage(this, host, port, database, databaseConfig, useSSL);
|
storage = new MySQLStorage(this, driver, host, port, database, databaseConfig, useSSL);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -5,13 +5,22 @@ import com.zaxxer.hikari.HikariConfig;
|
|||||||
|
|
||||||
public class MySQLStorage extends SQLStorage {
|
public class MySQLStorage extends SQLStorage {
|
||||||
|
|
||||||
public MySQLStorage(FastLoginCore<?, ?, ?> core, String host, int port, String database, HikariConfig config,
|
public MySQLStorage(FastLoginCore<?, ?, ?> core, String driver, String host, int port, String database,
|
||||||
boolean useSSL) {
|
HikariConfig config,boolean useSSL) {
|
||||||
super(core,
|
super(core,
|
||||||
"mysql://" + host + ':' + port + '/' + database,
|
buildJDBCUrl(driver, host, port, database),
|
||||||
setParams(config, useSSL));
|
setParams(config, useSSL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String buildJDBCUrl(String driver, String host, int port, String database) {
|
||||||
|
String protocol = "mysql";
|
||||||
|
if (driver.contains("mariadb")) {
|
||||||
|
protocol = "mariadb";
|
||||||
|
}
|
||||||
|
|
||||||
|
return protocol + "://" + host + ':' + port + '/' + database;
|
||||||
|
}
|
||||||
|
|
||||||
private static HikariConfig setParams(HikariConfig config, boolean useSSL) {
|
private static HikariConfig setParams(HikariConfig config, boolean useSSL) {
|
||||||
// Require SSL on the server if requested in config - this will also verify certificate
|
// Require SSL on the server if requested in config - this will also verify certificate
|
||||||
// Those values are deprecated in favor of sslMode
|
// Those values are deprecated in favor of sslMode
|
||||||
|
Reference in New Issue
Block a user