mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-24 17:47:40 +01:00
adding a function to check if a class exists, allows for better addition if other connector classes need to be checked in the future
This commit is contained in:
parent
0872a5bb35
commit
70c282ccd0
@ -292,16 +292,10 @@ 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.cj.jdbc.Driver");
|
||||
} catch (ClassNotFoundException cnfxLatestDriver){
|
||||
Log.warning("MySQL-JDBC Did not find 'com.mysql.cj.jdbc.Driver' trying 'com.mysql.jdbc.Driver' next");
|
||||
try {
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
} catch (ClassNotFoundException cnfx) {
|
||||
Log.severe("MySQL-JDBC classes not found - MySQL data source not usable");
|
||||
return false;
|
||||
}
|
||||
|
||||
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
|
||||
if(!initializeTables()) {
|
||||
@ -310,6 +304,15 @@ public class MySQLMapStorage extends MapStorage {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user