try {
Class.forName("com.mysql.jdbc.Driver");
Connection cc = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/registration", "root", "");
Statement s = (Statement) cc.createStatement();
ResultSet r = s.executeQuery("delete from students where nic=" + nic.getText() + "");
while (r.next()) {
name.setText(r.getString("Name"));
phone.setText(r.getString("Phone"));
email.setText(r.getString("Email"));
course.setSelectedItem(r.getString("Course"));
}
} catch (Exception e) {
e.printStackTrace();
}