Code snippet below shows how to delete records from database table using PreparedStatement.
PreparedStatement prepstmt;
try {
prepstmt = theConn.prepareStatement
("DELETE FROM tCust "+
" WHERE custId = ?");
prepstmt.setString(1,cust_id.getText());
prepstmt.executeUpdate();
theConn.commit();
prepstmt.close();
}
catch (Exception e) {
e.printStackTrace();
}