mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-01-18 16:35:25 +01:00
Abort onEnable() when driver not found
This commit is contained in:
parent
f0503c7797
commit
9668bb2ee7
@ -30,7 +30,6 @@ import snaq.db.ConnectionPool;
|
||||
|
||||
public final class SQLDatabaseManager implements DatabaseManager {
|
||||
private static final String ALL_QUERY_VERSION = "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy";
|
||||
private String connectionString;
|
||||
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
private final int POOL_FETCH_TIMEOUT = 0; // How long a method will wait for a connection. Since none are on main thread, we can safely say wait for as long as you like.
|
||||
@ -40,31 +39,32 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
private ConnectionPool connectionPool;
|
||||
|
||||
protected SQLDatabaseManager() {
|
||||
connectionString = "jdbc:mysql://" + Config.getInstance().getMySQLServerName() + ":" + Config.getInstance().getMySQLServerPort() + "/" + Config.getInstance().getMySQLDatabaseName();
|
||||
protected SQLDatabaseManager() throws ClassNotFoundException {
|
||||
String connectionString = "jdbc:mysql://" + Config.getInstance().getMySQLServerName() + ":" + Config.getInstance().getMySQLServerPort() + "/" + Config.getInstance().getMySQLDatabaseName();
|
||||
|
||||
try {
|
||||
// Force driver to load if not yet loaded
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
Properties connectionProperties = new Properties();
|
||||
connectionProperties.put("user", Config.getInstance().getMySQLUserName());
|
||||
connectionProperties.put("password", Config.getInstance().getMySQLUserPassword());
|
||||
connectionProperties.put("autoReconnect", "false");
|
||||
connectionPool = new ConnectionPool("mcMMO-Pool",
|
||||
1 /*Minimum of one*/,
|
||||
Config.getInstance().getMySQLMaxPoolSize() /*max pool size */,
|
||||
Config.getInstance().getMySQLMaxConnections() /*max num connections*/,
|
||||
0 /* idle timeout of connections */,
|
||||
connectionString,
|
||||
connectionProperties);
|
||||
connectionPool.init(); // Init first connection
|
||||
connectionPool.registerShutdownHook(); // Auto release on jvm exit just in case
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
// TODO tft do something here everything will blow up
|
||||
e.printStackTrace();
|
||||
throw e; // aborts onEnable()
|
||||
}
|
||||
|
||||
Properties connectionProperties = new Properties();
|
||||
connectionProperties.put("user", Config.getInstance().getMySQLUserName());
|
||||
connectionProperties.put("password", Config.getInstance().getMySQLUserPassword());
|
||||
connectionProperties.put("autoReconnect", "false");
|
||||
connectionPool = new ConnectionPool("mcMMO-Pool",
|
||||
1 /*Minimum of one*/,
|
||||
Config.getInstance().getMySQLMaxPoolSize() /*max pool size */,
|
||||
Config.getInstance().getMySQLMaxConnections() /*max num connections*/,
|
||||
0 /* idle timeout of connections */,
|
||||
connectionString,
|
||||
connectionProperties);
|
||||
connectionPool.init(); // Init first connection
|
||||
connectionPool.registerShutdownHook(); // Auto release on jvm exit just in case
|
||||
|
||||
checkStructure();
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user