Merge pull request #3477 from stormboomer/StormBoomer-Test1

Add requested Feature to check for MySQL Connector
This commit is contained in:
mikeprimm 2021-09-07 22:08:06 -05:00 committed by GitHub
commit 56a683b4b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -292,17 +292,25 @@ public class MySQLMapStorage extends MapStorage {
connectionString = "jdbc:mysql://" + hostname + ":" + port + "/" + database + flags; connectionString = "jdbc:mysql://" + hostname + ":" + port + "/" + database + flags;
Log.info("Opening MySQL database " + hostname + ":" + port + "/" + database + " as map store"); Log.info("Opening MySQL database " + hostname + ":" + port + "/" + database + " as map store");
try {
Class.forName("com.mysql.jdbc.Driver"); if(!hasClass("com.mysql.cj.jdbc.Driver") && !hasClass("com.mysql.jdbc.Driver")){
Log.severe("MySQL-JDBC classes not found - MySQL data source not usable");
return false;
}
// Initialize/update tables, if needed // Initialize/update tables, if needed
if(!initializeTables()) { if(!initializeTables()) {
return false; return false;
} }
return writeConfigPHP(core);
}
private boolean hasClass(String classname){
try{
Class.forName(classname);
return true;
} catch (ClassNotFoundException cnfx){ } catch (ClassNotFoundException cnfx){
Log.severe("MySQL-JDBC classes not found - MySQL data source not usable");
return false; return false;
} }
return writeConfigPHP(core);
} }
private boolean writeConfigPHP(DynmapCore core) { private boolean writeConfigPHP(DynmapCore core) {