'How to delete table records on cascade without the program freezing?
this is my delete button method, it takes the college name as a primary key and deletes it so the whole record gets deleted. However, it can't be deleted because this table COLLEGE is the parent table for the STUDENTS table and DEPARTMENT table. I want to delete on cascade but the button freezes when I click it but if I drop the foreign keys it works pretty well. To sum up, I want to delete the record on cascade without having any trouble in the JFrame.
College table

private void deleteActionPerformed(java.awt.event.ActionEvent evt) {
try{
String sql = " DELETE FROM college where college_name = ?";
conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","moe");
pst = conn.prepareStatement(sql);
pst.setString(1,college_name.getText());
pst.executeUpdate();
JOptionPane.showMessageDialog(null, "deleted successfully");
}
catch (Exception ex) {
JOptionPane.showMessageDialog(null,ex);
}
showData();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
