Refactored to remove abstraction.
This commit is contained in:
@@ -55,7 +55,7 @@ public class dbBlueprintHandler extends dbHandlerBase {
|
|||||||
int recordsRead = 0;
|
int recordsRead = 0;
|
||||||
|
|
||||||
try (Connection connection = DbManager.getConnection();
|
try (Connection connection = DbManager.getConnection();
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `obj_account` WHERE `acct_uname`=?")) {
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_building_blueprint")) {
|
||||||
|
|
||||||
ResultSet rs = preparedStatement.executeQuery();
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,12 @@
|
|||||||
|
|
||||||
package engine.db.handlers;
|
package engine.db.handlers;
|
||||||
|
|
||||||
|
import engine.gameManager.DbManager;
|
||||||
import engine.objects.Boon;
|
import engine.objects.Boon;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -20,32 +23,29 @@ public class dbBoonHandler extends dbHandlerBase {
|
|||||||
|
|
||||||
public dbBoonHandler() {
|
public dbBoonHandler() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public ArrayList<Boon> GET_BOON_AMOUNTS_FOR_ITEMBASEUUID(int itemBaseUUID){
|
|
||||||
|
|
||||||
ArrayList<Boon>boons = new ArrayList<>();
|
|
||||||
Boon thisBoon;
|
|
||||||
prepareCallable("SELECT * FROM `static_item_boons` WHERE `itemBaseID` = ?");
|
|
||||||
setInt(1, itemBaseUUID);
|
|
||||||
|
|
||||||
try {
|
public ArrayList<Boon> GET_BOON_AMOUNTS_FOR_ITEMBASE(int itemBaseUUID) {
|
||||||
ResultSet rs = executeQuery();
|
|
||||||
|
ArrayList<Boon> boons = new ArrayList<>();
|
||||||
while (rs.next()) {
|
Boon thisBoon;
|
||||||
|
|
||||||
|
try (Connection connection = DbManager.getConnection();
|
||||||
thisBoon = new Boon(rs);
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_item_boons` WHERE `itemBaseID` = ?")) {
|
||||||
boons.add(thisBoon);
|
|
||||||
|
preparedStatement.setInt(1, itemBaseUUID);
|
||||||
|
|
||||||
|
ResultSet rs = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
while (rs.next()) {
|
||||||
|
thisBoon = new Boon(rs);
|
||||||
|
boons.add(thisBoon);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
Logger.error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return boons;
|
||||||
|
|
||||||
} catch (SQLException e) {
|
|
||||||
Logger.error("GetBoonAmountsForItembaseUUID: " + e.getErrorCode() + ' ' + e.getMessage(), e);
|
|
||||||
} finally {
|
|
||||||
closeCallable();
|
|
||||||
}
|
}
|
||||||
return boons;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class Boon {
|
|||||||
|
|
||||||
public static void HandleBoonListsForItemBase(int itemBaseID){
|
public static void HandleBoonListsForItemBase(int itemBaseID){
|
||||||
ArrayList<Boon> boons = null;
|
ArrayList<Boon> boons = null;
|
||||||
boons = DbManager.BoonQueries.GET_BOON_AMOUNTS_FOR_ITEMBASEUUID(itemBaseID);
|
boons = DbManager.BoonQueries.GET_BOON_AMOUNTS_FOR_ITEMBASE(itemBaseID);
|
||||||
if (boons != null)
|
if (boons != null)
|
||||||
GetBoonsForItemBase.put(itemBaseID, boons);
|
GetBoonsForItemBase.put(itemBaseID, boons);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user