mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-10-31 21:47:10 +00:00
Fix autoclosing on resultsets
This commit is contained in:
parent
c26e05c392
commit
74408b85bf
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user