diff --git a/src/engine/db/handlers/dbEffectsBaseHandler.java b/src/engine/db/handlers/dbEffectsBaseHandler.java index 95735e15..f6a86848 100644 --- a/src/engine/db/handlers/dbEffectsBaseHandler.java +++ b/src/engine/db/handlers/dbEffectsBaseHandler.java @@ -9,11 +9,14 @@ package engine.db.handlers; -import engine.objects.PreparedStatementShared; +import engine.gameManager.DbManager; import engine.powers.EffectsBase; import org.pmw.tinylog.Logger; +import java.sql.Connection; +import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; import java.util.ArrayList; public class dbEffectsBaseHandler extends dbHandlerBase { @@ -22,24 +25,24 @@ public class dbEffectsBaseHandler extends dbHandlerBase { } - public static ArrayList getAllEffectsBase() { - PreparedStatementShared ps = null; - ArrayList out = new ArrayList<>(); - try { - ps = new PreparedStatementShared("SELECT * FROM static_power_effectbase ORDER BY `IDString` DESC"); - ResultSet rs = ps.executeQuery(); + + ArrayList effectList = new ArrayList<>(); + + try (Connection connection = DbManager.getConnection(); + PreparedStatement prepareStatement = connection.prepareStatement("SELECT * FROM static_power_effectbase ORDER BY `IDString` DESC")) { + + ResultSet rs = prepareStatement.executeQuery(); + while (rs.next()) { EffectsBase toAdd = new EffectsBase(rs); - out.add(toAdd); + effectList.add(toAdd); } - rs.close(); - } catch (Exception e) { - Logger.error(e); - } finally { - ps.release(); + } catch (SQLException e) { + Logger.error(e.toString()); } - //testHash(out); - return out; + + return effectList; } + }