mirror of
https://github.com/TuxCoding/FastLogin.git
synced 2025-07-29 10:17:38 +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.setPassword(config.getString("password"));
|
||||
storage = new MySQLStorage(this, host, port, database, databaseConfig, useSSL);
|
||||
storage = new MySQLStorage(this, driver, host, port, database, databaseConfig, useSSL);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -5,13 +5,22 @@ import com.zaxxer.hikari.HikariConfig;
|
||||
|
||||
public class MySQLStorage extends SQLStorage {
|
||||
|
||||
public MySQLStorage(FastLoginCore<?, ?, ?> core, String host, int port, String database, HikariConfig config,
|
||||
boolean useSSL) {
|
||||
public MySQLStorage(FastLoginCore<?, ?, ?> core, String driver, String host, int port, String database,
|
||||
HikariConfig config,boolean useSSL) {
|
||||
super(core,
|
||||
"mysql://" + host + ':' + port + '/' + database,
|
||||
buildJDBCUrl(driver, host, port, database),
|
||||
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) {
|
||||
// Require SSL on the server if requested in config - this will also verify certificate
|
||||
// Those values are deprecated in favor of sslMode
|
||||
|
Reference in New Issue
Block a user