Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void delete_btnMouseClicked(java.awt.event.MouseEvent evt) {
- // TODO add your handling code here:
- int delete = JOptionPane.showConfirmDialog(this, "Are you sure you want to delete nthis person from your contacts?", "Delete Contact", JOptionPane.YES_NO_CANCEL_OPTION);
- int indexno = jList1.getSelectedIndex();
- if (delete == 1) {
- jList1.setModel(dlm);
- dlm.removeElementAt(indexno);
- try {
- String update = "delete from contacts where user = '" + Login.jTextField1.getText() + "' and contacts = '" + jList1.getSelectedValue() + "';";
- Login.connectionUpdate(update);
- }
- catch (Exception e){
- e.printStackTrace();
- }
- }
- }
- public static void connectionUpdate(String update) throws ClassNotFoundException, SQLException {
- Class.forName("java.sql.DriverManager");
- Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/chatroom", "root", "ForbiddenVoices!");
- Statement stmt = (Statement) con.createStatement();
- String check = update;
- stmt.executeUpdate(check);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement