mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-24 11:15:19 +01:00
Change getAccountsRegistered method to use normal Statement.
- Log the stacktrace if something weird happens.
This commit is contained in:
parent
1f001f2225
commit
c196f45854
@ -259,8 +259,9 @@ public class MySQL implements DataSource {
|
||||
pst.setString(1, user.toLowerCase());
|
||||
ResultSet rs = pst.executeQuery();
|
||||
return rs.next();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -312,8 +313,9 @@ public class MySQL implements DataSource {
|
||||
pAuth.setHash(new String(bytes));
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
return null;
|
||||
}
|
||||
return pAuth;
|
||||
@ -521,8 +523,9 @@ public class MySQL implements DataSource {
|
||||
pst.close();
|
||||
}
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -574,8 +577,9 @@ public class MySQL implements DataSource {
|
||||
pst.close();
|
||||
}
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -602,7 +606,7 @@ public class MySQL implements DataSource {
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
return false;
|
||||
@ -625,8 +629,9 @@ public class MySQL implements DataSource {
|
||||
PreparedStatement pst = con.prepareStatement(sql);
|
||||
pst.setLong(1, until);
|
||||
result = pst.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -653,8 +658,9 @@ public class MySQL implements DataSource {
|
||||
sql = "DELETE FROM " + tableName + " WHERE " + columnLastLogin + "<" + until;
|
||||
st.executeUpdate(sql);
|
||||
st.close();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@ -693,8 +699,9 @@ public class MySQL implements DataSource {
|
||||
pst.setString(1, user);
|
||||
pst.executeUpdate();
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -723,8 +730,9 @@ public class MySQL implements DataSource {
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -751,8 +759,9 @@ public class MySQL implements DataSource {
|
||||
}
|
||||
rs.close();
|
||||
pst.close();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
return countIp;
|
||||
}
|
||||
@ -776,7 +785,7 @@ public class MySQL implements DataSource {
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
@ -805,8 +814,9 @@ public class MySQL implements DataSource {
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -820,9 +830,10 @@ public class MySQL implements DataSource {
|
||||
public void reload() {
|
||||
try {
|
||||
reloadArguments();
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL configuration!");
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
AuthMe.getInstance().stopOrUnload();
|
||||
}
|
||||
}
|
||||
@ -861,8 +872,9 @@ public class MySQL implements DataSource {
|
||||
}
|
||||
rs.close();
|
||||
pst.close();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -889,8 +901,9 @@ public class MySQL implements DataSource {
|
||||
}
|
||||
rs.close();
|
||||
pst.close();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -938,8 +951,9 @@ public class MySQL implements DataSource {
|
||||
pst.executeUpdate();
|
||||
}
|
||||
pst.close();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -969,8 +983,9 @@ public class MySQL implements DataSource {
|
||||
pst.setString(1, user);
|
||||
ResultSet rs = pst.executeQuery();
|
||||
isLogged = rs.next() && (rs.getInt(columnLogged) == 1);
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
return isLogged;
|
||||
}
|
||||
@ -991,8 +1006,9 @@ public class MySQL implements DataSource {
|
||||
pst.setString(2, user.toLowerCase());
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1012,8 +1028,9 @@ public class MySQL implements DataSource {
|
||||
pst.setString(2, user.toLowerCase());
|
||||
pst.executeUpdate();
|
||||
pst.close();
|
||||
} catch (Exception ex) {
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1033,6 +1050,7 @@ public class MySQL implements DataSource {
|
||||
pst.close();
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1047,15 +1065,16 @@ public class MySQL implements DataSource {
|
||||
public int getAccountsRegistered() {
|
||||
int result = 0;
|
||||
try (Connection con = getConnection()) {
|
||||
PreparedStatement pst = con.prepareStatement("SELECT COUNT(*) FROM " + tableName + ";");
|
||||
ResultSet rs = pst.executeQuery();
|
||||
Statement st = con.createStatement();
|
||||
ResultSet rs = st.executeQuery("SELECT COUNT(*) FROM " + tableName);
|
||||
if (rs.next()) {
|
||||
result = rs.getInt(1);
|
||||
}
|
||||
rs.close();
|
||||
pst.close();
|
||||
st.close();
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -1078,6 +1097,7 @@ public class MySQL implements DataSource {
|
||||
pst.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1131,6 +1151,7 @@ public class MySQL implements DataSource {
|
||||
st.close();
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
return auths;
|
||||
}
|
||||
@ -1182,6 +1203,7 @@ public class MySQL implements DataSource {
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
ConsoleLogger.writeStackTrace(ex);
|
||||
}
|
||||
return auths;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user