forked from MagicBane/Server
Refactored out duplicate db interface.
This commit is contained in:
@@ -9,9 +9,11 @@
|
||||
|
||||
package engine.powers;
|
||||
|
||||
import engine.objects.PreparedStatementShared;
|
||||
import engine.gameManager.DbManager;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
@@ -60,14 +62,17 @@ public class PowerPrereq {
|
||||
}
|
||||
|
||||
public static void getAllPowerPrereqs(HashMap<String, PowersBase> powers) {
|
||||
PreparedStatementShared ps = null;
|
||||
try {
|
||||
ps = new PreparedStatementShared("SELECT * FROM static_power_powercastprereq");
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
try (Connection connection = DbManager.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_powercastprereq\"")) {
|
||||
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
|
||||
int type;
|
||||
String IDString;
|
||||
PowerPrereq toAdd;
|
||||
PowersBase pb;
|
||||
|
||||
while (rs.next()) {
|
||||
IDString = rs.getString("IDString");
|
||||
pb = powers.get(IDString);
|
||||
@@ -85,8 +90,6 @@ public class PowerPrereq {
|
||||
rs.close();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.toString());
|
||||
} finally {
|
||||
ps.release();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user