mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Add a configuration to print jdbc exceptions
By default, mcmmo tries to pretty print errors, which is fine for many cases, however; deeper nested errors can lack information, e.g. networking related issues, while the pretty print is less intimitating and provides useful information to users, surpressing the trace can prevent debugging these deeper issues, this config option serves as a compromise between scaring users and having a means to find these deeper issues.
This commit is contained in:
parent
8951c1fd21
commit
8a4410cde8
@ -341,6 +341,7 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
public int getMySQLMaxConnections(PoolIdentifier identifier) { return config.getInt("MySQL.Database.MaxConnections." + StringUtils.getCapitalized(identifier.toString()), 30); }
|
||||
public int getMySQLMaxPoolSize(PoolIdentifier identifier) { return config.getInt("MySQL.Database.MaxPoolSize." + StringUtils.getCapitalized(identifier.toString()), 10); }
|
||||
public boolean getMySQLSSL() { return config.getBoolean("MySQL.Server.SSL", true); }
|
||||
public boolean getMySQLDebug() { return config.getBoolean("MySQL.Debug", false); }
|
||||
|
||||
private String getStringIncludingInts(String key) {
|
||||
String str = config.getString(key);
|
||||
|
@ -31,6 +31,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
private DataSource loadPool;
|
||||
private DataSource savePool;
|
||||
|
||||
private boolean debug = false;
|
||||
|
||||
private ReentrantLock massUpdateLock = new ReentrantLock();
|
||||
|
||||
protected SQLDatabaseManager() {
|
||||
@ -56,6 +58,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
//throw e; // aborts onEnable() Riking if you want to do this, fully implement it.
|
||||
}
|
||||
|
||||
debug = Config.getInstance().getMySQLDebug();
|
||||
|
||||
|
||||
PoolProperties poolProperties = new PoolProperties();
|
||||
poolProperties.setDriverClassName("com.mysql.jdbc.Driver");
|
||||
@ -1148,6 +1152,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
private void printErrors(SQLException ex) {
|
||||
if (debug) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
StackTraceElement element = ex.getStackTrace()[0];
|
||||
mcMMO.p.getLogger().severe("Location: " + element.getClassName() + " " + element.getMethodName() + " " + element.getLineNumber());
|
||||
mcMMO.p.getLogger().severe("SQLException: " + ex.getMessage());
|
||||
|
@ -146,6 +146,7 @@ Backups:
|
||||
###
|
||||
MySQL:
|
||||
Enabled: false
|
||||
Debug: false
|
||||
Database:
|
||||
User_Name: UserName
|
||||
User_Password: UserPassword
|
||||
|
Loading…
Reference in New Issue
Block a user