Close resources in MySQL (incomplete)
- Connection, (Prepared)Statement and ResultSet all should be closed. try-with-resources is the best way as it's less verbose than a finally block and it's better than putting close() calls inside the try{} as that will not be run if an exception happens beforehand
This commit is contained in:
parent
bb0d938141
commit
dfa3921740
@ -234,66 +234,72 @@ public class MySQL implements DataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean isAuthAvailable(String user) {
|
public synchronized boolean isAuthAvailable(String user) {
|
||||||
try (Connection con = getConnection()) {
|
String sql = "SELECT " + col.NAME + " FROM " + tableName + " WHERE " + col.NAME + "=?;";
|
||||||
String sql = "SELECT " + col.NAME + " FROM " + tableName + " WHERE " + col.NAME + "=?;";
|
ResultSet rs = null;
|
||||||
PreparedStatement pst = con.prepareStatement(sql);
|
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
|
||||||
pst.setString(1, user.toLowerCase());
|
pst.setString(1, user.toLowerCase());
|
||||||
ResultSet rs = pst.executeQuery();
|
rs = pst.executeQuery();
|
||||||
return rs.next();
|
return rs.next();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logSqlException(ex);
|
logSqlException(ex);
|
||||||
|
} finally {
|
||||||
|
close(rs);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashedPassword getPassword(String user) {
|
public HashedPassword getPassword(String user) {
|
||||||
try (Connection con = getConnection()) {
|
String sql = "SELECT " + col.PASSWORD + "," + col.SALT + " FROM " + tableName
|
||||||
String sql = "SELECT " + col.PASSWORD + "," + col.SALT + " FROM " + tableName
|
+ " WHERE " + col.NAME + "=?;";
|
||||||
+ " WHERE " + col.NAME + "=?;";
|
ResultSet rs = null;
|
||||||
PreparedStatement pst = con.prepareStatement(sql);
|
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
|
||||||
pst.setString(1, user.toLowerCase());
|
pst.setString(1, user.toLowerCase());
|
||||||
ResultSet rs = pst.executeQuery();
|
rs = pst.executeQuery();
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
return new HashedPassword(rs.getString(col.PASSWORD),
|
return new HashedPassword(rs.getString(col.PASSWORD),
|
||||||
!col.SALT.isEmpty() ? rs.getString(col.SALT) : null);
|
!col.SALT.isEmpty() ? rs.getString(col.SALT) : null);
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logSqlException(ex);
|
logSqlException(ex);
|
||||||
|
} finally {
|
||||||
|
close(rs);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized PlayerAuth getAuth(String user) {
|
public synchronized PlayerAuth getAuth(String user) {
|
||||||
PlayerAuth pAuth;
|
String sql = "SELECT * FROM " + tableName + " WHERE " + col.NAME + "=?;";
|
||||||
try (Connection con = getConnection()) {
|
PlayerAuth auth;
|
||||||
String sql = "SELECT * FROM " + tableName + " WHERE " + col.NAME + "=?;";
|
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
|
||||||
PreparedStatement pst = con.prepareStatement(sql);
|
|
||||||
pst.setString(1, user.toLowerCase());
|
pst.setString(1, user.toLowerCase());
|
||||||
ResultSet rs = pst.executeQuery();
|
int id;
|
||||||
if (!rs.next()) {
|
try (ResultSet rs = pst.executeQuery()) {
|
||||||
return null;
|
if (!rs.next()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
id = rs.getInt(col.ID);
|
||||||
|
auth = buildAuthFromResultSet(rs);
|
||||||
}
|
}
|
||||||
int id = rs.getInt(col.ID);
|
|
||||||
pAuth = buildAuthFromResultSet(rs);
|
|
||||||
rs.close();
|
|
||||||
pst.close();
|
|
||||||
if (hashAlgorithm == HashAlgorithm.XFBCRYPT) {
|
if (hashAlgorithm == HashAlgorithm.XFBCRYPT) {
|
||||||
pst = con.prepareStatement("SELECT data FROM xf_user_authenticate WHERE " + col.ID + "=?;");
|
try (PreparedStatement pst2 = con.prepareStatement(
|
||||||
pst.setInt(1, id);
|
"SELECT data FROM xf_user_authenticate WHERE " + col.ID + "=?;")) {
|
||||||
rs = pst.executeQuery();
|
pst2.setInt(1, id);
|
||||||
if (rs.next()) {
|
try (ResultSet rs = pst2.executeQuery()) {
|
||||||
Blob blob = rs.getBlob("data");
|
if (rs.next()) {
|
||||||
byte[] bytes = blob.getBytes(1, (int) blob.length());
|
Blob blob = rs.getBlob("data");
|
||||||
pAuth.setPassword(new HashedPassword(XFBCRYPT.getHashFromBlob(bytes)));
|
byte[] bytes = blob.getBytes(1, (int) blob.length());
|
||||||
|
auth.setPassword(new HashedPassword(XFBCRYPT.getHashFromBlob(bytes)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return auth;
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logSqlException(ex);
|
logSqlException(ex);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
return pAuth;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -580,20 +586,19 @@ public class MySQL implements DataSource {
|
|||||||
@Override
|
@Override
|
||||||
public synchronized List<String> autoPurgeDatabase(long until) {
|
public synchronized List<String> autoPurgeDatabase(long until) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
try (Connection con = getConnection()) {
|
String select = "SELECT " + col.NAME + " FROM " + tableName + " WHERE " + col.LAST_LOGIN + "<?;";
|
||||||
String sql = "SELECT " + col.NAME + " FROM " + tableName + " WHERE " + col.LAST_LOGIN + "<?;";
|
String delete = "DELETE FROM " + tableName + " WHERE " + col.LAST_LOGIN + "<?;";
|
||||||
PreparedStatement st = con.prepareStatement(sql);
|
try (Connection con = getConnection();
|
||||||
st.setLong(1, until);
|
PreparedStatement selectPst = con.prepareStatement(select);
|
||||||
ResultSet rs = st.executeQuery();
|
PreparedStatement deletePst = con.prepareStatement(delete)) {
|
||||||
while (rs.next()) {
|
selectPst.setLong(1, until);
|
||||||
list.add(rs.getString(col.NAME));
|
try (ResultSet rs = selectPst.executeQuery()) {
|
||||||
|
while (rs.next()) {
|
||||||
|
list.add(rs.getString(col.NAME));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rs.close();
|
deletePst.setLong(1, until);
|
||||||
sql = "DELETE FROM " + tableName + " WHERE " + col.LAST_LOGIN + "<?;";
|
deletePst.executeUpdate();
|
||||||
st = con.prepareStatement(sql);
|
|
||||||
st.setLong(1, until);
|
|
||||||
st.executeUpdate();
|
|
||||||
st.close();
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logSqlException(ex);
|
logSqlException(ex);
|
||||||
}
|
}
|
||||||
@ -634,18 +639,16 @@ public class MySQL implements DataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean updateQuitLoc(PlayerAuth auth) {
|
public synchronized boolean updateQuitLoc(PlayerAuth auth) {
|
||||||
try (Connection con = getConnection()) {
|
String sql = "UPDATE " + tableName
|
||||||
String sql = "UPDATE " + tableName
|
+ " SET " + col.LASTLOC_X + " =?, " + col.LASTLOC_Y + "=?, " + col.LASTLOC_Z + "=?, " + col.LASTLOC_WORLD + "=?"
|
||||||
+ " SET " + col.LASTLOC_X + " =?, " + col.LASTLOC_Y + "=?, " + col.LASTLOC_Z + "=?, " + col.LASTLOC_WORLD + "=?"
|
+ " WHERE " + col.NAME + "=?;";
|
||||||
+ " WHERE " + col.NAME + "=?;";
|
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
|
||||||
PreparedStatement pst = con.prepareStatement(sql);
|
|
||||||
pst.setDouble(1, auth.getQuitLocX());
|
pst.setDouble(1, auth.getQuitLocX());
|
||||||
pst.setDouble(2, auth.getQuitLocY());
|
pst.setDouble(2, auth.getQuitLocY());
|
||||||
pst.setDouble(3, auth.getQuitLocZ());
|
pst.setDouble(3, auth.getQuitLocZ());
|
||||||
pst.setString(4, auth.getWorld());
|
pst.setString(4, auth.getWorld());
|
||||||
pst.setString(5, auth.getNickname());
|
pst.setString(5, auth.getNickname());
|
||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
pst.close();
|
|
||||||
return true;
|
return true;
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logSqlException(ex);
|
logSqlException(ex);
|
||||||
@ -655,13 +658,11 @@ public class MySQL implements DataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean updateEmail(PlayerAuth auth) {
|
public synchronized boolean updateEmail(PlayerAuth auth) {
|
||||||
try (Connection con = getConnection()) {
|
String sql = "UPDATE " + tableName + " SET " + col.EMAIL + " =? WHERE " + col.NAME + "=?;";
|
||||||
String sql = "UPDATE " + tableName + " SET " + col.EMAIL + " =? WHERE " + col.NAME + "=?;";
|
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
|
||||||
PreparedStatement pst = con.prepareStatement(sql);
|
|
||||||
pst.setString(1, auth.getEmail());
|
pst.setString(1, auth.getEmail());
|
||||||
pst.setString(2, auth.getNickname());
|
pst.setString(2, auth.getNickname());
|
||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
pst.close();
|
|
||||||
return true;
|
return true;
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logSqlException(ex);
|
logSqlException(ex);
|
||||||
@ -690,16 +691,14 @@ public class MySQL implements DataSource {
|
|||||||
@Override
|
@Override
|
||||||
public synchronized List<String> getAllAuthsByIp(String ip) {
|
public synchronized List<String> getAllAuthsByIp(String ip) {
|
||||||
List<String> result = new ArrayList<>();
|
List<String> result = new ArrayList<>();
|
||||||
try (Connection con = getConnection()) {
|
String sql = "SELECT " + col.NAME + " FROM " + tableName + " WHERE " + col.IP + "=?;";
|
||||||
String sql = "SELECT " + col.NAME + " FROM " + tableName + " WHERE " + col.IP + "=?;";
|
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
|
||||||
PreparedStatement pst = con.prepareStatement(sql);
|
|
||||||
pst.setString(1, ip);
|
pst.setString(1, ip);
|
||||||
ResultSet rs = pst.executeQuery();
|
try (ResultSet rs = pst.executeQuery()) {
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
result.add(rs.getString(col.NAME));
|
result.add(rs.getString(col.NAME));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rs.close();
|
|
||||||
pst.close();
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logSqlException(ex);
|
logSqlException(ex);
|
||||||
}
|
}
|
||||||
@ -708,32 +707,29 @@ public class MySQL implements DataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized List<String> getAllAuthsByEmail(String email) {
|
public synchronized List<String> getAllAuthsByEmail(String email) {
|
||||||
List<String> countEmail = new ArrayList<>();
|
List<String> emails = new ArrayList<>();
|
||||||
try (Connection con = getConnection()) {
|
String sql = "SELECT " + col.NAME + " FROM " + tableName + " WHERE " + col.EMAIL + "=?;";
|
||||||
String sql = "SELECT " + col.NAME + " FROM " + tableName + " WHERE " + col.EMAIL + "=?;";
|
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
|
||||||
PreparedStatement pst = con.prepareStatement(sql);
|
|
||||||
pst.setString(1, email);
|
pst.setString(1, email);
|
||||||
ResultSet rs = pst.executeQuery();
|
try (ResultSet rs = pst.executeQuery()) {
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
countEmail.add(rs.getString(col.NAME));
|
emails.add(rs.getString(col.NAME));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rs.close();
|
|
||||||
pst.close();
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logSqlException(ex);
|
logSqlException(ex);
|
||||||
}
|
}
|
||||||
return countEmail;
|
return emails;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void purgeBanned(List<String> banned) {
|
public synchronized void purgeBanned(List<String> banned) {
|
||||||
try (Connection con = getConnection()) {
|
String sql = "DELETE FROM " + tableName + " WHERE " + col.NAME + "=?;";
|
||||||
PreparedStatement pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + col.NAME + "=?;");
|
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
|
||||||
for (String name : banned) {
|
for (String name : banned) {
|
||||||
pst.setString(1, name);
|
pst.setString(1, name);
|
||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
}
|
}
|
||||||
pst.close();
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logSqlException(ex);
|
logSqlException(ex);
|
||||||
}
|
}
|
||||||
@ -746,28 +742,25 @@ public class MySQL implements DataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isLogged(String user) {
|
public boolean isLogged(String user) {
|
||||||
boolean isLogged = false;
|
String sql = "SELECT " + col.IS_LOGGED + " FROM " + tableName + " WHERE " + col.NAME + "=?;";
|
||||||
try (Connection con = getConnection()) {
|
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
|
||||||
String sql = "SELECT " + col.IS_LOGGED + " FROM " + tableName + " WHERE " + col.NAME + "=?;";
|
|
||||||
PreparedStatement pst = con.prepareStatement(sql);
|
|
||||||
pst.setString(1, user);
|
pst.setString(1, user);
|
||||||
ResultSet rs = pst.executeQuery();
|
try (ResultSet rs = pst.executeQuery()) {
|
||||||
isLogged = rs.next() && (rs.getInt(col.IS_LOGGED) == 1);
|
return rs.next() && (rs.getInt(col.IS_LOGGED) == 1);
|
||||||
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logSqlException(ex);
|
logSqlException(ex);
|
||||||
}
|
}
|
||||||
return isLogged;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLogged(String user) {
|
public void setLogged(String user) {
|
||||||
try (Connection con = getConnection()) {
|
String sql = "UPDATE " + tableName + " SET " + col.IS_LOGGED + "=? WHERE " + col.NAME + "=?;";
|
||||||
String sql = "UPDATE " + tableName + " SET " + col.IS_LOGGED + "=? WHERE " + col.NAME + "=?;";
|
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
|
||||||
PreparedStatement pst = con.prepareStatement(sql);
|
|
||||||
pst.setInt(1, 1);
|
pst.setInt(1, 1);
|
||||||
pst.setString(2, user.toLowerCase());
|
pst.setString(2, user.toLowerCase());
|
||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
pst.close();
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logSqlException(ex);
|
logSqlException(ex);
|
||||||
}
|
}
|
||||||
@ -775,13 +768,11 @@ public class MySQL implements DataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUnlogged(String user) {
|
public void setUnlogged(String user) {
|
||||||
try (Connection con = getConnection()) {
|
String sql = "UPDATE " + tableName + " SET " + col.IS_LOGGED + "=? WHERE " + col.NAME + "=?;";
|
||||||
String sql = "UPDATE " + tableName + " SET " + col.IS_LOGGED + "=? WHERE " + col.NAME + "=?;";
|
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
|
||||||
PreparedStatement pst = con.prepareStatement(sql);
|
|
||||||
pst.setInt(1, 0);
|
pst.setInt(1, 0);
|
||||||
pst.setString(2, user.toLowerCase());
|
pst.setString(2, user.toLowerCase());
|
||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
pst.close();
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logSqlException(ex);
|
logSqlException(ex);
|
||||||
}
|
}
|
||||||
@ -789,13 +780,11 @@ public class MySQL implements DataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void purgeLogged() {
|
public void purgeLogged() {
|
||||||
try (Connection con = getConnection()) {
|
String sql = "UPDATE " + tableName + " SET " + col.IS_LOGGED + "=? WHERE " + col.IS_LOGGED + "=?;";
|
||||||
String sql = "UPDATE " + tableName + " SET " + col.IS_LOGGED + "=? WHERE " + col.IS_LOGGED + "=?;";
|
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
|
||||||
PreparedStatement pst = con.prepareStatement(sql);
|
|
||||||
pst.setInt(1, 0);
|
pst.setInt(1, 0);
|
||||||
pst.setInt(2, 1);
|
pst.setInt(2, 1);
|
||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
pst.close();
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logSqlException(ex);
|
logSqlException(ex);
|
||||||
}
|
}
|
||||||
@ -804,14 +793,13 @@ public class MySQL implements DataSource {
|
|||||||
@Override
|
@Override
|
||||||
public int getAccountsRegistered() {
|
public int getAccountsRegistered() {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
try (Connection con = getConnection()) {
|
String sql = "SELECT COUNT(*) FROM " + tableName;
|
||||||
Statement st = con.createStatement();
|
try (Connection con = getConnection();
|
||||||
ResultSet rs = st.executeQuery("SELECT COUNT(*) FROM " + tableName);
|
Statement st = con.createStatement();
|
||||||
|
ResultSet rs = st.executeQuery(sql)) {
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
result = rs.getInt(1);
|
result = rs.getInt(1);
|
||||||
}
|
}
|
||||||
rs.close();
|
|
||||||
st.close();
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
logSqlException(ex);
|
logSqlException(ex);
|
||||||
}
|
}
|
||||||
@ -820,9 +808,8 @@ public class MySQL implements DataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateName(String oldOne, String newOne) {
|
public void updateName(String oldOne, String newOne) {
|
||||||
try (Connection con = getConnection()) {
|
String sql = "UPDATE " + tableName + " SET " + col.NAME + "=? WHERE " + col.NAME + "=?;";
|
||||||
String sql = "UPDATE " + tableName + " SET " + col.NAME + "=? WHERE " + col.NAME + "=?;";
|
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
|
||||||
PreparedStatement pst = con.prepareStatement(sql);
|
|
||||||
pst.setString(1, newOne);
|
pst.setString(1, newOne);
|
||||||
pst.setString(2, oldOne);
|
pst.setString(2, oldOne);
|
||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
@ -833,9 +820,8 @@ public class MySQL implements DataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateRealName(String user, String realName) {
|
public boolean updateRealName(String user, String realName) {
|
||||||
try (Connection con = getConnection()) {
|
String sql = "UPDATE " + tableName + " SET " + col.REAL_NAME + "=? WHERE " + col.NAME + "=?;";
|
||||||
String sql = "UPDATE " + tableName + " SET " + col.REAL_NAME + "=? WHERE " + col.NAME + "=?;";
|
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
|
||||||
PreparedStatement pst = con.prepareStatement(sql);
|
|
||||||
pst.setString(1, realName);
|
pst.setString(1, realName);
|
||||||
pst.setString(2, user);
|
pst.setString(2, user);
|
||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
@ -848,9 +834,8 @@ public class MySQL implements DataSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateIp(String user, String ip) {
|
public boolean updateIp(String user, String ip) {
|
||||||
try (Connection con = getConnection()) {
|
String sql = "UPDATE " + tableName + " SET " + col.IP + "=? WHERE " + col.NAME + "=?;";
|
||||||
String sql = "UPDATE " + tableName + " SET " + col.IP + "=? WHERE " + col.NAME + "=?;";
|
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
|
||||||
PreparedStatement pst = con.prepareStatement(sql);
|
|
||||||
pst.setString(1, ip);
|
pst.setString(1, ip);
|
||||||
pst.setString(2, user);
|
pst.setString(2, user);
|
||||||
pst.executeUpdate();
|
pst.executeUpdate();
|
||||||
@ -1002,4 +987,14 @@ public class MySQL implements DataSource {
|
|||||||
ConsoleLogger.logException("Error during SQL operation:", e);
|
ConsoleLogger.logException("Error during SQL operation:", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void close(ResultSet rs) {
|
||||||
|
if (rs != null) {
|
||||||
|
try {
|
||||||
|
rs.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
ConsoleLogger.logException("Could not close ResultSet", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user