mirror of
https://github.com/webbukkit/dynmap.git
synced 2025-01-12 19:00:44 +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,17 +292,11 @@ 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.cj.jdbc.Driver");
|
if(!hasClass("com.mysql.cj.jdbc.Driver") && !hasClass("com.mysql.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");
|
Log.severe("MySQL-JDBC classes not found - MySQL data source not usable");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Initialize/update tables, if needed
|
// Initialize/update tables, if needed
|
||||||
if(!initializeTables()) {
|
if(!initializeTables()) {
|
||||||
return false;
|
return false;
|
||||||
@ -310,6 +304,15 @@ public class MySQLMapStorage extends MapStorage {
|
|||||||
return writeConfigPHP(core);
|
return writeConfigPHP(core);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean hasClass(String classname){
|
||||||
|
try{
|
||||||
|
Class.forName(classname);
|
||||||
|
return true;
|
||||||
|
} catch (ClassNotFoundException cnfx){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean writeConfigPHP(DynmapCore core) {
|
private boolean writeConfigPHP(DynmapCore core) {
|
||||||
File cfgfile = new File(baseStandaloneDir, "MySQL_config.php");
|
File cfgfile = new File(baseStandaloneDir, "MySQL_config.php");
|
||||||
if (!core.isInternalWebServerDisabled) { // If using internal server
|
if (!core.isInternalWebServerDisabled) { // If using internal server
|
||||||
|
Loading…
Reference in New Issue
Block a user