This tutorial entitled Delete Data using MySQL Database and Java with Netbeans IDE will help you on how to create a Delete features using your Java and Netbeans.
This is the continuation of my last topic entitled How to Load Data from MySQL Database to Table Element in Java. This program can delete data from a selected row of data from Java table. Follow all the steps to complete this tutorial.
Delete Data using MySQL Database and Java with Netbeans IDE
- Add a new button inside your load data form and rename the button text to “Delete”. We use that button for our delete function.
2. Double click the new created button and insert the following codes below.
String id = (jTable1.getModel().getValueAt(row, 0).toString());
String nna = (jTable1.getModel().getValueAt(row, 1).toString()) + ” ” + (jTable1.getModel().getValueAt(row, 2).toString());
int p = JOptionPane.showConfirmDialog(null, “Are you sure you want to delete ” + nna + “?”,”Delete”,JOptionPane.YES_NO_OPTION);
String str=”DELETE FROM userinfo WHERE idUserInfo='” + id + “‘”;
3. Run your program and the output should look like the image below. When the user click the delete button, a confirmation box appear asking the user to delete the item or not. If the user select yes, the data selected from the table will be deleted.
About The Delete Data using MySQL Database In Java
|Project Name:||Delete Data using MySQL Database|
Related Articles You May Like:
- Display Text Field Value to Another Text Field in Java
- VAT Sales Receipt Calculator in Java
- Load Image from Path to JLabel in Java
- Save Data to MySQL in Java using Netbeans
- How to Play MP3 Music in Java
- Create MySQL Connection in Java