Fixed an issue where a ResultSet in SpawnerService was never closed

This commit is contained in:
Mads Boddum
2015-09-10 15:15:26 +02:00
parent fbf0475950
commit ad7b5c0b9a
+6 -5
View File
@@ -47,12 +47,14 @@ import services.objects.ObjectManager;
public final class SpawnerService extends Service {
private static final String GET_ALL_SPAWNERS_SQL =
"SELECT static.*, buildings.object_id, buildings.terrain_name FROM static "
+ "INNER JOIN buildings ON static.building_id = buildings.building_id "
+ "GROUP BY buildings.building_id";
private final ObjectManager objectManager;
private final Collection<Spawner> spawners;
private final RelationalServerData spawnerDatabase;
private static final String QUERY = "SELECT static.*, buildings.object_id, buildings.terrain_name FROM static "
+ "INNER JOIN buildings ON static.building_id = buildings.building_id "
+ "GROUP BY buildings.building_id";
public SpawnerService(ObjectManager objectManager) {
this.objectManager = objectManager;
@@ -102,8 +104,7 @@ public final class SpawnerService extends Service {
}
private void loadSpawners() {
try {
ResultSet jointTable = spawnerDatabase.prepareStatement(QUERY).executeQuery();
try(ResultSet jointTable = spawnerDatabase.prepareStatement(GET_ALL_SPAWNERS_SQL).executeQuery()) {
while (jointTable.next()) {
if(jointTable.getBoolean("active")) {
Location loc = new Location(jointTable.getFloat("x"), jointTable.getFloat("y"), jointTable.getFloat("z"), Terrain.valueOf(jointTable.getString("terrain_name")));