From 35c16b1faeb0a5c5c8222e142b0fc57edab19c44 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 28 Dec 2021 16:16:16 +0100 Subject: [PATCH] Try with resources Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/sql/FightPlayer.java | 14 +++++++------- src/de/steamwar/bungeecore/sql/SteamwarUser.java | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/de/steamwar/bungeecore/sql/FightPlayer.java b/src/de/steamwar/bungeecore/sql/FightPlayer.java index e2f118d..a4e1192 100644 --- a/src/de/steamwar/bungeecore/sql/FightPlayer.java +++ b/src/de/steamwar/bungeecore/sql/FightPlayer.java @@ -30,13 +30,13 @@ public class FightPlayer { if(fightIds.isEmpty()) return fightPlayers; - Statement batch = new Statement("SELECT * FROM FightPlayer WHERE FightID IN (" + fightIds.stream().map(Object::toString).collect(Collectors.joining(", ")) + ")"); - batch.select(rs -> { - while(rs.next()) - fightPlayers.add(new FightPlayer(rs)); - return null; - }); - batch.close(); + try (Statement batch = new Statement("SELECT * FROM FightPlayer WHERE FightID IN (" + fightIds.stream().map(Object::toString).collect(Collectors.joining(", ")) + ")")) { + batch.select(rs -> { + while(rs.next()) + fightPlayers.add(new FightPlayer(rs)); + return null; + }); + } return fightPlayers; } diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java index f52ce57..86d5d02 100644 --- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java +++ b/src/de/steamwar/bungeecore/sql/SteamwarUser.java @@ -193,13 +193,13 @@ public class SteamwarUser { if(ids.isEmpty()) return; - Statement batch = new Statement("SELECT * FROM UserData WHERE id IN (" + ids.stream().map(Object::toString).collect(Collectors.joining(", ")) + ")"); - batch.select(rs -> { - while(rs.next()) - new SteamwarUser(rs); - return null; - }); - batch.close(); + try (Statement batch = new Statement("SELECT * FROM UserData WHERE id IN (" + ids.stream().map(Object::toString).collect(Collectors.joining(", ")) + ")")) { + batch.select(rs -> { + while (rs.next()) + new SteamwarUser(rs); + return null; + }); + } } public static SteamwarUser get(Long discordId) {