From abb2521f585309e1a8fef6afaf91d70f3fc47d8d Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 26 May 2023 17:46:26 -0400 Subject: [PATCH] Bug class involving generated keys from statements. --- src/engine/db/handlers/dbCharacterPowerHandler.java | 7 ++----- src/engine/db/handlers/dbCharacterRuneHandler.java | 7 ++----- src/engine/db/handlers/dbCharacterSkillHandler.java | 7 ++----- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/engine/db/handlers/dbCharacterPowerHandler.java b/src/engine/db/handlers/dbCharacterPowerHandler.java index 3a2bbcf8..f16f67fb 100644 --- a/src/engine/db/handlers/dbCharacterPowerHandler.java +++ b/src/engine/db/handlers/dbCharacterPowerHandler.java @@ -16,10 +16,7 @@ import engine.objects.PlayerCharacter; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; +import java.sql.*; import java.util.concurrent.ConcurrentHashMap; public class dbCharacterPowerHandler extends dbHandlerBase { @@ -39,7 +36,7 @@ public class dbCharacterPowerHandler extends dbHandlerBase { } try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_character_power` (`CharacterID`, `powersBaseToken`, `trains`) VALUES (?, ?, ?);")) { + PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_character_power` (`CharacterID`, `powersBaseToken`, `trains`) VALUES (?, ?, ?);", Statement.RETURN_GENERATED_KEYS)) { preparedStatement.setLong(1, CharacterPower.getOwner(toAdd).getObjectUUID()); preparedStatement.setInt(2, toAdd.getPower().getToken()); diff --git a/src/engine/db/handlers/dbCharacterRuneHandler.java b/src/engine/db/handlers/dbCharacterRuneHandler.java index d63bc6d8..7cdbed5c 100644 --- a/src/engine/db/handlers/dbCharacterRuneHandler.java +++ b/src/engine/db/handlers/dbCharacterRuneHandler.java @@ -14,10 +14,7 @@ import engine.gameManager.DbManager; import engine.objects.CharacterRune; import org.pmw.tinylog.Logger; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; +import java.sql.*; import java.util.ArrayList; public class dbCharacterRuneHandler extends dbHandlerBase { @@ -32,7 +29,7 @@ public class dbCharacterRuneHandler extends dbHandlerBase { CharacterRune characterRune = null; try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_character_rune` (`CharacterID`, `RuneBaseID`) VALUES (?, ?);")) { + PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_character_rune` (`CharacterID`, `RuneBaseID`) VALUES (?, ?);", Statement.RETURN_GENERATED_KEYS)) { preparedStatement.setLong(1, toAdd.getPlayerID()); preparedStatement.setInt(2, toAdd.getRuneBaseID()); diff --git a/src/engine/db/handlers/dbCharacterSkillHandler.java b/src/engine/db/handlers/dbCharacterSkillHandler.java index fd46d5c5..beb9b5bf 100644 --- a/src/engine/db/handlers/dbCharacterSkillHandler.java +++ b/src/engine/db/handlers/dbCharacterSkillHandler.java @@ -17,10 +17,7 @@ import engine.objects.PlayerCharacter; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; +import java.sql.*; import java.util.concurrent.ConcurrentHashMap; public class dbCharacterSkillHandler extends dbHandlerBase { @@ -40,7 +37,7 @@ public class dbCharacterSkillHandler extends dbHandlerBase { } try (Connection connection = DbManager.getConnection(); - PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_character_skill` (`CharacterID`, `skillsBaseID`, `trains`) VALUES (?, ?, ?);")) { + PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `dyn_character_skill` (`CharacterID`, `skillsBaseID`, `trains`) VALUES (?, ?, ?);", Statement.RETURN_GENERATED_KEYS)) { preparedStatement.setLong(1, CharacterSkill.GetOwner(toAdd).getObjectUUID()); preparedStatement.setInt(2, toAdd.getSkillsBase().getObjectUUID());