mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Better connection validation for us.
This commit is contained in:
parent
be9ff51fd9
commit
fc981fda20
@ -29,7 +29,9 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.runnables.database.UUIDUpdateAsyncTask;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
import snaq.db.CacheConnection;
|
||||
import snaq.db.ConnectionPool;
|
||||
import snaq.db.ConnectionValidator;
|
||||
|
||||
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";
|
||||
@ -73,6 +75,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
0 /* idle timeout of connections */,
|
||||
connectionString,
|
||||
connectionProperties);
|
||||
miscPool.setValidator(new mcMMOValidator());
|
||||
loadPool = new ConnectionPool("mcMMO-Load-Pool",
|
||||
1 /*Minimum of one*/,
|
||||
Config.getInstance().getMySQLMaxPoolSize(PoolIdentifier.LOAD) /*max pool size */,
|
||||
@ -80,6 +83,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
0 /* idle timeout of connections */,
|
||||
connectionString,
|
||||
connectionProperties);
|
||||
loadPool.setValidator(new mcMMOValidator());
|
||||
savePool = new ConnectionPool("mcMMO-Save-Pool",
|
||||
1 /*Minimum of one*/,
|
||||
Config.getInstance().getMySQLMaxPoolSize(PoolIdentifier.SAVE) /*max pool size */,
|
||||
@ -87,6 +91,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
0 /* idle timeout of connections */,
|
||||
connectionString,
|
||||
connectionProperties);
|
||||
savePool.setValidator(new mcMMOValidator());
|
||||
miscPool.init(); // Init first connection
|
||||
miscPool.registerShutdownHook(); // Auto release on jvm exit just in case
|
||||
loadPool.init();
|
||||
@ -1604,4 +1609,12 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
LOAD,
|
||||
SAVE;
|
||||
}
|
||||
|
||||
private class mcMMOValidator implements ConnectionValidator {
|
||||
@Override
|
||||
public boolean isValid(Connection connection) throws SQLException {
|
||||
return connection instanceof CacheConnection && connection.isValid(10);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user