Browse Source

Bug class involving generated keys from statements.

master
MagicBot 1 year ago
parent
commit
abb2521f58
  1. 7
      src/engine/db/handlers/dbCharacterPowerHandler.java
  2. 7
      src/engine/db/handlers/dbCharacterRuneHandler.java
  3. 7
      src/engine/db/handlers/dbCharacterSkillHandler.java

7
src/engine/db/handlers/dbCharacterPowerHandler.java

@ -16,10 +16,7 @@ import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.sql.Connection; import java.sql.*;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public class dbCharacterPowerHandler extends dbHandlerBase { public class dbCharacterPowerHandler extends dbHandlerBase {
@ -39,7 +36,7 @@ public class dbCharacterPowerHandler extends dbHandlerBase {
} }
try (Connection connection = DbManager.getConnection(); 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.setLong(1, CharacterPower.getOwner(toAdd).getObjectUUID());
preparedStatement.setInt(2, toAdd.getPower().getToken()); preparedStatement.setInt(2, toAdd.getPower().getToken());

7
src/engine/db/handlers/dbCharacterRuneHandler.java

@ -14,10 +14,7 @@ import engine.gameManager.DbManager;
import engine.objects.CharacterRune; import engine.objects.CharacterRune;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.sql.Connection; import java.sql.*;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
public class dbCharacterRuneHandler extends dbHandlerBase { public class dbCharacterRuneHandler extends dbHandlerBase {
@ -32,7 +29,7 @@ public class dbCharacterRuneHandler extends dbHandlerBase {
CharacterRune characterRune = null; CharacterRune characterRune = null;
try (Connection connection = DbManager.getConnection(); 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.setLong(1, toAdd.getPlayerID());
preparedStatement.setInt(2, toAdd.getRuneBaseID()); preparedStatement.setInt(2, toAdd.getRuneBaseID());

7
src/engine/db/handlers/dbCharacterSkillHandler.java

@ -17,10 +17,7 @@ import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.sql.Connection; import java.sql.*;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public class dbCharacterSkillHandler extends dbHandlerBase { public class dbCharacterSkillHandler extends dbHandlerBase {
@ -40,7 +37,7 @@ public class dbCharacterSkillHandler extends dbHandlerBase {
} }
try (Connection connection = DbManager.getConnection(); 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.setLong(1, CharacterSkill.GetOwner(toAdd).getObjectUUID());
preparedStatement.setInt(2, toAdd.getSkillsBase().getObjectUUID()); preparedStatement.setInt(2, toAdd.getSkillsBase().getObjectUUID());

Loading…
Cancel
Save