This commit is contained in:
sgdc3 2017-10-20 00:11:42 +02:00
parent ea824ea3f0
commit 251eca9ccd
2 changed files with 4 additions and 4 deletions

View File

@ -574,7 +574,7 @@ public class MySQL implements DataSource {
public boolean hasSession(String user) { public boolean hasSession(String user) {
String sql = "SELECT " + col.HAS_SESSION + " FROM " + tableName + " WHERE " + col.NAME + "=?;"; String sql = "SELECT " + col.HAS_SESSION + " FROM " + tableName + " WHERE " + col.NAME + "=?;";
try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) { try (Connection con = getConnection(); PreparedStatement pst = con.prepareStatement(sql)) {
pst.setString(1, user); pst.setString(1, user.toLowerCase());
try (ResultSet rs = pst.executeQuery()) { try (ResultSet rs = pst.executeQuery()) {
return rs.next() && (rs.getInt(col.HAS_SESSION) == 1); return rs.next() && (rs.getInt(col.HAS_SESSION) == 1);
} }

View File

@ -474,7 +474,7 @@ public class SQLite implements DataSource {
public boolean hasSession(String user) { public boolean hasSession(String user) {
String sql = "SELECT " + col.HAS_SESSION + " FROM " + tableName + " WHERE LOWER(" + col.NAME + ")=?;"; String sql = "SELECT " + col.HAS_SESSION + " FROM " + tableName + " WHERE LOWER(" + col.NAME + ")=?;";
try (PreparedStatement pst = con.prepareStatement(sql)) { try (PreparedStatement pst = con.prepareStatement(sql)) {
pst.setString(1, user); pst.setString(1, user.toLowerCase());
try (ResultSet rs = pst.executeQuery()) { try (ResultSet rs = pst.executeQuery()) {
if (rs.next()) { if (rs.next()) {
return rs.getInt(col.HAS_SESSION) == 1; return rs.getInt(col.HAS_SESSION) == 1;
@ -491,7 +491,7 @@ public class SQLite implements DataSource {
String sql = "UPDATE " + tableName + " SET " + col.HAS_SESSION + "=? WHERE LOWER(" + col.NAME + ")=?;"; String sql = "UPDATE " + tableName + " SET " + col.HAS_SESSION + "=? WHERE LOWER(" + col.NAME + ")=?;";
try (PreparedStatement pst = con.prepareStatement(sql)) { try (PreparedStatement pst = con.prepareStatement(sql)) {
pst.setInt(1, 1); pst.setInt(1, 1);
pst.setString(2, user); pst.setString(2, user.toLowerCase());
pst.executeUpdate(); pst.executeUpdate();
} catch (SQLException ex) { } catch (SQLException ex) {
logSqlException(ex); logSqlException(ex);
@ -503,7 +503,7 @@ public class SQLite implements DataSource {
String sql = "UPDATE " + tableName + " SET " + col.HAS_SESSION + "=? WHERE LOWER(" + col.NAME + ")=?;"; String sql = "UPDATE " + tableName + " SET " + col.HAS_SESSION + "=? WHERE LOWER(" + col.NAME + ")=?;";
try (PreparedStatement pst = con.prepareStatement(sql)) { try (PreparedStatement pst = con.prepareStatement(sql)) {
pst.setInt(1, 0); pst.setInt(1, 0);
pst.setString(2, user); pst.setString(2, user.toLowerCase());
pst.executeUpdate(); pst.executeUpdate();
} catch (SQLException ex) { } catch (SQLException ex) {
logSqlException(ex); logSqlException(ex);