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,19 +292,27 @@ public class MySQLMapStorage extends MapStorage {
connectionString = "jdbc:mysql://" + hostname + ":" + port + "/" + database + flags;
Log.info("Opening MySQL database " + hostname + ":" + port + "/" + database + " as map store");
try {
Class.forName("com.mysql.jdbc.Driver");
// Initialize/update tables, if needed
if(!initializeTables()) {
return false;
}
} catch (ClassNotFoundException cnfx) {
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;
return false;
}
// Initialize/update tables, if needed
if(!initializeTables()) {
return false;
}
return writeConfigPHP(core);
}
private boolean hasClass(String classname){
try{
Class.forName(classname);
return true;
} catch (ClassNotFoundException cnfx){
return false;
}
}
private boolean writeConfigPHP(DynmapCore core) {
File cfgfile = new File(baseStandaloneDir, "MySQL_config.php");
if (!core.isInternalWebServerDisabled) { // If using internal server