From 6223c62efc0a0cee254281d788d7a7e2da69bb4f Mon Sep 17 00:00:00 2001 From: DiddiZ Date: Tue, 13 Dec 2011 13:35:50 +0100 Subject: [PATCH] Added workaround for numbers as mysql user names, passwords and databases --- src/de/diddiz/LogBlock/Config.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/de/diddiz/LogBlock/Config.java b/src/de/diddiz/LogBlock/Config.java index 81af883..975b562 100644 --- a/src/de/diddiz/LogBlock/Config.java +++ b/src/de/diddiz/LogBlock/Config.java @@ -114,9 +114,12 @@ public class Config extends LoggingEnabledMapping if (!config.contains(e.getKey())) config.set(e.getKey(), e.getValue()); logblock.saveConfig(); - url = "jdbc:mysql://" + config.getString("mysql.host") + ":" + config.getInt("mysql.port") + "/" + config.getString("mysql.database"); - user = config.getString("mysql.user"); - password = config.getString("mysql.password"); + url = "jdbc:mysql://" + config.getString("mysql.host") + ":" + config.getInt("mysql.port") + "/" + getStringIncludingInts(config, "mysql.database"); + String username = config.getString("mysql.user"); + if (username == null) + username = String.valueOf(config.getInt("mysql.user")); + user = getStringIncludingInts(config, "mysql.user"); + password = getStringIncludingInts(config, "mysql.password"); delayBetweenRuns = config.getInt("consumer.delayBetweenRuns", 6); forceToProcessAtLeast = config.getInt("consumer.forceToProcessAtLeast", 0); timePerRun = config.getInt("consumer.timePerRun", 100); @@ -194,7 +197,15 @@ public class Config extends LoggingEnabledMapping for (final Logging l : Logging.values()) if (wcfg.isLogging(l)) setLogging(l, true); + } + private static String getStringIncludingInts(ConfigurationSection cfg, String key) { + String str = cfg.getString(key); + if (str == null) + str = String.valueOf(cfg.getInt(key)); + if (str == null) + str = "No value set for '" + key + "'"; + return str; } }