Update MySQL driver class name

+ implement fallback to the legacy driver
This commit is contained in:
Gabriele C 2021-08-21 22:54:36 +02:00
parent d969d314b3
commit 18c31e3a42
4 changed files with 17 additions and 6 deletions

View File

@ -1,5 +1,5 @@
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
<!-- File auto-generated on Sun Apr 04 21:31:43 CEST 2021. See docs/config/config.tpl.md -->
<!-- File auto-generated on Sat Aug 21 22:53:23 CEST 2021. See docs/config/config.tpl.md -->
## AuthMe Configuration
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
@ -29,7 +29,7 @@ DataSource:
# Password to connect to the MySQL database
mySQLPassword: '12345'
# Driver Name of the MySQL database
mySQLDriverClassName: com.mysql.jdbc.Driver
mySQLDriverClassName: com.mysql.cj.jdbc.Driver
# Database Name, use with converters or as SQLITE database name
mySQLDatabase: authme
# Table of the database
@ -89,7 +89,7 @@ ExternalBoardOptions:
# Other MySQL columns where we need to put the username (case-sensitive)
mySQLOtherUsernameColumns: []
# How much log2 rounds needed in BCrypt (do not change if you do not know what it does)
bCryptLog2Round: 10
bCryptLog2Round: 12
# phpBB table prefix defined during the phpBB installation process
phpbbTablePrefix: phpbb_
# phpBB activated group ID; 2 is the default registered group defined by phpBB
@ -587,4 +587,4 @@ To change settings on a running server, save your changes to config.yml and use
---
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sun Apr 04 21:31:43 CEST 2021
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sat Aug 21 22:53:23 CEST 2021

View File

@ -101,6 +101,12 @@ public class MySQL extends AbstractSqlDataSource {
this.username = settings.getProperty(DatabaseSettings.MYSQL_USERNAME);
this.password = settings.getProperty(DatabaseSettings.MYSQL_PASSWORD);
this.className = settings.getProperty(DatabaseSettings.MYSQL_DRIVER_CLASS_NAME);
try {
Class.forName(this.className);
} catch (ClassNotFoundException e) {
logger.info("Driver class '" + this.className + "' not found! Falling back to legacy MySQL driver (com.mysql.jdbc.Driver)");
this.className = "com.mysql.jdbc.Driver";
}
this.database = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
this.tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
this.columnOthers = settings.getProperty(HooksSettings.MYSQL_OTHER_USERNAME_COLS);
@ -122,7 +128,7 @@ public class MySQL extends AbstractSqlDataSource {
// Pool Settings
ds.setMaximumPoolSize(poolSize);
ds.setMaxLifetime(maxLifetime * 1000);
ds.setMaxLifetime(maxLifetime * 1000L);
// Database URL
ds.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database);

View File

@ -60,10 +60,15 @@ public class SettingsMigrationService extends PlainMigrationService {
@SuppressWarnings("checkstyle:BooleanExpressionComplexity")
protected boolean performMigrations(PropertyReader reader, ConfigurationData configurationData) {
boolean changes = false;
if ("[a-zA-Z0-9_?]*".equals(reader.getString(ALLOWED_NICKNAME_CHARACTERS.getPath()))) {
configurationData.setValue(ALLOWED_NICKNAME_CHARACTERS, "[a-zA-Z0-9_]*");
changes = true;
}
if ("com.mysql.jdbc.Driver".equals(reader.getString(DatabaseSettings.MYSQL_DRIVER_CLASS_NAME.getPath()))) {
configurationData.setValue(DatabaseSettings.MYSQL_DRIVER_CLASS_NAME, "com.mysql.cj.jdbc.Driver");
changes = true;
}
setOldOtherAccountsCommandFieldsIfSet(reader);

View File

@ -47,7 +47,7 @@ public final class DatabaseSettings implements SettingsHolder {
@Comment("Driver Name of the MySQL database")
public static final Property<String> MYSQL_DRIVER_CLASS_NAME =
newProperty("DataSource.mySQLDriverClassName", "com.mysql.jdbc.Driver");
newProperty("DataSource.mySQLDriverClassName", "com.mysql.cj.jdbc.Driver");
@Comment("Database Name, use with converters or as SQLITE database name")
public static final Property<String> MYSQL_DATABASE =