bug fixes

This commit is contained in:
Tyler Murphy 2022-09-04 10:54:59 -04:00
parent 7932ef8bc5
commit da258dd365

View file

@ -55,13 +55,20 @@ public class SelfRoleTable {
} }
public boolean deleteData(long guildId, int page){ public boolean deleteData(long guildId, int page){
String sql = "DELETE FROM self_role_data WHERE guild_id = ? AND page = ?; UPDATE self_role_data SET page = page - 1 WHERE guild_id = ? AND page > ?;"; try(Connection connection = database.connect();) {
try(Connection connection = database.connect(); PreparedStatement statement = connection.prepareStatement(sql)) { String sql = "DELETE FROM self_role_data WHERE guild_id = ? AND page = ?;";
statement.setLong(1, guildId); try(PreparedStatement statement = connection.prepareStatement(sql)){
statement.setInt(2, page); statement.setLong(1, guildId);
statement.setLong(3, guildId); statement.setInt(2, page);
statement.setInt(4, page); statement.executeUpdate();
return statement.executeUpdate() != 0; }
sql = "UPDATE self_role_data SET page = page - 1 WHERE guild_id = ? AND page > ?;";
try(PreparedStatement statement = connection.prepareStatement(sql)){
statement.setLong(1, guildId);
statement.setInt(2, page);
statement.executeUpdate();
}
return true;
} catch (SQLException e) { } catch (SQLException e) {
Ken.getInstance().getLogger().error("SQL Error: " + e.getMessage()); Ken.getInstance().getLogger().error("SQL Error: " + e.getMessage());
return false; return false;