diff --git a/src/main/java/fr/xephi/authme/datasource/SQLite.java b/src/main/java/fr/xephi/authme/datasource/SQLite.java index f98edc0d..f0462840 100644 --- a/src/main/java/fr/xephi/authme/datasource/SQLite.java +++ b/src/main/java/fr/xephi/authme/datasource/SQLite.java @@ -31,8 +31,9 @@ public class SQLite implements DataSource { * Constructor for SQLite. * * @param settings The settings instance + * * @throws ClassNotFoundException if no driver could be found for the datasource - * @throws SQLException when initialization of a SQL datasource failed + * @throws SQLException when initialization of a SQL datasource failed */ public SQLite(NewSetting settings) throws ClassNotFoundException, SQLException { this.database = settings.getProperty(DatabaseSettings.MYSQL_DATABASE); @@ -56,6 +57,10 @@ public class SQLite implements DataSource { this.con = connection; } + private static void logSqlException(SQLException e) { + ConsoleLogger.logException("Error while executing SQL statement:", e); + } + private synchronized void connect() throws ClassNotFoundException, SQLException { Class.forName("org.sqlite.JDBC"); ConsoleLogger.info("SQLite driver loaded"); @@ -283,24 +288,23 @@ public class SQLite implements DataSource { @Override public List autoPurgeDatabase(long until) { - PreparedStatement pst = null; - ResultSet rs = null; List list = new ArrayList<>(); - try { - pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + col.LAST_LOGIN + "(); + return list; } @Override @@ -521,7 +525,7 @@ public class SQLite implements DataSource { @Override public boolean updateRealName(String user, String realName) { String sql = "UPDATE " + tableName + " SET " + col.REAL_NAME + "=? WHERE " + col.NAME + "=?;"; - try(PreparedStatement pst = con.prepareStatement(sql)) { + try (PreparedStatement pst = con.prepareStatement(sql)) { pst.setString(1, realName); pst.setString(2, user); pst.executeUpdate(); @@ -535,7 +539,7 @@ public class SQLite implements DataSource { @Override public boolean updateIp(String user, String ip) { String sql = "UPDATE " + tableName + " SET " + col.IP + "=? WHERE " + col.NAME + "=?;"; - try(PreparedStatement pst = con.prepareStatement(sql)) { + try (PreparedStatement pst = con.prepareStatement(sql)) { pst.setString(1, ip); pst.setString(2, user); pst.executeUpdate(); @@ -592,10 +596,6 @@ public class SQLite implements DataSource { return false; } - private static void logSqlException(SQLException e) { - ConsoleLogger.logException("Error while executing SQL statement:", e); - } - private PlayerAuth buildAuthFromResultSet(ResultSet row) throws SQLException { String salt = !col.SALT.isEmpty() ? row.getString(col.SALT) : null;