diff --git a/commons/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java b/commons/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java index 3db0902c..5c4b200d 100644 --- a/commons/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java +++ b/commons/src/main/java/me/totalfreedom/totalfreedommod/sql/SQLite.java @@ -127,18 +127,12 @@ public class SQLite extends FreedomService public ResultSet getBanList() throws SQLException { - try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM bans")) - { - return statement.executeQuery(); - } + return connection.prepareStatement("SELECT * FROM bans").executeQuery(); } public ResultSet getAdminList() throws SQLException { - try (PreparedStatement statement = connection.prepareStatement("SELECT * FROM admins")) - { - return statement.executeQuery(); - } + return connection.prepareStatement("SELECT * FROM admins").executeQuery(); } public void setAdminValue(Admin admin, String key, Object value) @@ -264,8 +258,11 @@ public class SQLite extends FreedomService public ResultSet getAdminByUuid(UUID uuid) { - try (ResultSet resultSet = connection.createStatement().executeQuery(MessageFormat.format("SELECT * FROM admins WHERE uuid=''{0}''", uuid.toString()))) + try { + PreparedStatement statement = connection.prepareStatement("SELECT * FROM admins WHERE uuid=?"); + statement.setString(1, uuid.toString()); + ResultSet resultSet = statement.executeQuery(); if (resultSet.next()) { return resultSet; @@ -281,8 +278,12 @@ public class SQLite extends FreedomService public ResultSet getPlayerByUuid(UUID uuid) { - try (ResultSet resultSet = connection.createStatement().executeQuery(MessageFormat.format("SELECT * FROM players WHERE uuid=''{0}''", uuid.toString()))) + try { + PreparedStatement statement = connection.prepareStatement("SELECT * FROM players WHERE uuid=?"); + statement.setString(1, uuid.toString()); + ResultSet resultSet = statement.executeQuery(); + if (resultSet.next()) { return resultSet; @@ -298,9 +299,9 @@ public class SQLite extends FreedomService public ResultSet getMasterBuilders() { - try (ResultSet resultSet = connection.createStatement().executeQuery("SELECT * FROM players WHERE master_builder=true")) + try { - return resultSet; + return connection.prepareStatement("SELECT * FROM players WHERE master_builder=true").executeQuery(); } catch (SQLException e) { FLog.severe("Failed to get Master Builders:"); @@ -312,8 +313,11 @@ public class SQLite extends FreedomService public ResultSet getPlayerByIp(String ip) { - try (ResultSet resultSet = connection.createStatement().executeQuery(MessageFormat.format("SELECT * FROM players WHERE ips LIKE ''%{0}%''", ip))) + try { + PreparedStatement statement = connection.prepareStatement("SELECT * FROM players WHERE ips LIKE %?%"); + statement.setString(1, ip); + ResultSet resultSet = statement.executeQuery(); if (resultSet.next()) { return resultSet;