connectionString doesn't need to be its own variable anymore

This commit is contained in:
zreed 2014-07-30 11:09:48 -04:00
parent 77546e53f4
commit e9dd0713d6

View File

@ -31,7 +31,6 @@ import snaq.db.ConnectionPool;
public final class SQLDatabaseManager implements DatabaseManager { 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 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 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. 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.
@ -42,8 +41,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
private ConnectionPool connectionPool; private ConnectionPool connectionPool;
protected SQLDatabaseManager() { protected SQLDatabaseManager() {
connectionString = "jdbc:mysql://" + Config.getInstance().getMySQLServerName() + ":" + Config.getInstance().getMySQLServerPort() + "/" + Config.getInstance().getMySQLDatabaseName();
try { try {
// Force driver to load if not yet loaded // Force driver to load if not yet loaded
Class.forName("com.mysql.jdbc.Driver"); Class.forName("com.mysql.jdbc.Driver");
@ -56,7 +53,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
Config.getInstance().getMySQLMaxPoolSize() /*max pool size */, Config.getInstance().getMySQLMaxPoolSize() /*max pool size */,
Config.getInstance().getMySQLMaxConnections() /*max num connections*/, Config.getInstance().getMySQLMaxConnections() /*max num connections*/,
0 /* idle timeout of connections */, 0 /* idle timeout of connections */,
connectionString, "jdbc:mysql://" + Config.getInstance().getMySQLServerName() + ":" + Config.getInstance().getMySQLServerPort() + "/" + Config.getInstance().getMySQLDatabaseName(),
connectionProperties); connectionProperties);
connectionPool.init(); // Init first connection connectionPool.init(); // Init first connection
connectionPool.registerShutdownHook(); // Auto release on jvm exit just in case connectionPool.registerShutdownHook(); // Auto release on jvm exit just in case