Advertisement
Guest User

Untitled

a guest
Jul 13th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. private void delete_btnMouseClicked(java.awt.event.MouseEvent evt) {
  2. // TODO add your handling code here:
  3. int delete = JOptionPane.showConfirmDialog(this, "Are you sure you want to delete nthis person from your contacts?", "Delete Contact", JOptionPane.YES_NO_CANCEL_OPTION);
  4. int indexno = jList1.getSelectedIndex();
  5. if (delete == 1) {
  6. jList1.setModel(dlm);
  7. dlm.removeElementAt(indexno);
  8. try {
  9. String update = "delete from contacts where user = '" + Login.jTextField1.getText() + "' and contacts = '" + jList1.getSelectedValue() + "';";
  10. Login.connectionUpdate(update);
  11. }
  12. catch (Exception e){
  13. e.printStackTrace();
  14. }
  15. }
  16. }
  17.  
  18. public static void connectionUpdate(String update) throws ClassNotFoundException, SQLException {
  19. Class.forName("java.sql.DriverManager");
  20. Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/chatroom", "root", "ForbiddenVoices!");
  21. Statement stmt = (Statement) con.createStatement();
  22. String check = update;
  23. stmt.executeUpdate(check);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement