9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-19 15:09:19 +00:00

feat: add more logic for dealing with closed connections, closes #140

This commit is contained in:
LoJoSho
2024-06-06 19:38:53 -05:00
parent ca5e0f96c2
commit ab8656ad1a

View File

@@ -13,6 +13,7 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Properties;
import java.util.UUID;
import java.util.logging.Level;
public class MySQLData extends SQLData {
@@ -132,7 +133,14 @@ public class MySQLData extends SQLData {
public PreparedStatement preparedStatement(String query) {
PreparedStatement ps = null;
if (!isConnectionOpen()) MessagesUtil.sendDebugMessages("Connection is not open");
if (!isConnectionOpen()) {
MessagesUtil.sendDebugMessages("The MySQL database connection is not open (Could the database been idle for to long?). Reconnecting...", Level.WARNING);
try {
openConnection();
} catch (SQLException e) {
e.printStackTrace();
}
}
try {
if (connection == null) throw new NullPointerException("Connection is null");