mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2025-11-18 06:24:17 +01:00
Fix SQL memory leaks
This commit is contained in:
parent
5dd2959b06
commit
c484b4cf4d
@ -9,8 +9,6 @@ import net.Indyuce.mmocore.manager.data.yaml.YAMLDatabaseImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
@ -32,13 +30,14 @@ public class PlayerDataTableUpdater {
|
||||
+ ") VALUES('" + effectiveId + "'," + formatCollection(requestMap.values(), true) + ")" +
|
||||
" ON DUPLICATE KEY UPDATE " + formatMap() + ";";
|
||||
|
||||
try (Connection connection = provider.getConnection()) {
|
||||
final PreparedStatement statement = connection.prepareStatement(request);
|
||||
try (var connection = provider.getConnection();
|
||||
var statement = connection.prepareStatement(request)) {
|
||||
statement.executeUpdate();
|
||||
} catch (SQLException exception) {
|
||||
MMOCore.log(Level.WARNING, "Could not save player data of " + effectiveId + ", saving through YAML instead");
|
||||
new YAMLDatabaseImpl().saveData(playerData, saveReason);
|
||||
MMOCore.log(Level.WARNING, "Could not save player data of " + effectiveId + ", saving to YAML instead");
|
||||
exception.printStackTrace();
|
||||
|
||||
new YAMLDatabaseImpl().saveData(playerData, saveReason);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@ public class SQLDatabaseImpl extends SQLDatabase<PlayerData, OfflinePlayerData>
|
||||
public static final String UUID_FIELD_NAME = "uuid";
|
||||
|
||||
public SQLDatabaseImpl() {
|
||||
super(MMOCore.plugin, UUID_FIELD_NAME);
|
||||
super(MMOCore.plugin, UUID_FIELD_NAME);
|
||||
}
|
||||
|
||||
private static final String[] NEW_COLUMNS = new String[]{
|
||||
@ -53,8 +53,7 @@ public class SQLDatabaseImpl extends SQLDatabase<PlayerData, OfflinePlayerData>
|
||||
"stellium", "FLOAT"};
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
|
||||
protected void setupSQL() throws SQLException {
|
||||
// Fully create table
|
||||
executeUpdate("CREATE TABLE IF NOT EXISTS " + userdataTableName + "("
|
||||
+ UUID_FIELD_NAME + " VARCHAR(36)," +
|
||||
|
||||
Loading…
Reference in New Issue
Block a user