Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void removeFriend(String friendName) throws SQLException {
- for (int i = 0; i < 24; i++) {
- if (friends[i] != null && friends[i].equals(friendName)) {
- friends[i] = null;
- Connection con = DatabaseConnection.getConnection();
- PreparedStatement ps = con.prepareStatement("DELETE FROM friends WHERE username = ? AND friend = ?");
- ps.setString(1, username);
- ps.setString(2, friendName);
- ps.executeUpdate();
- ps.close();
- con.close();
- return;
- }
- }
- }
- public void removeFriend(String friendName) {
- for (Friend friend : friends) {
- if (friend.getFriendName().equals(friendName)) {
- Session session = DatabaseConnection.getSession();
- session.beginTransaction();
- session.delete(friend);
- session.getTransaction().commit();
- session.close();
- friends.remove(friend);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement