diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java index 9fb8a79ce..14c1d8b67 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java @@ -81,11 +81,14 @@ public class MySQLDB extends SQLDB { public Connection getConnection() throws SQLException { Connection connection = dataSource.getConnection(); if (!connection.isValid(5)) { + connection.close(); if (dataSource instanceof HikariDataSource) { ((HikariDataSource) dataSource).close(); } try { setupDataSource(); + // get new connection after restarting pool + return dataSource.getConnection(); } catch (DBInitException e) { throw new DBOpException("Failed to restart DataSource after a connection was invalid: " + e.getMessage(), e); }