Delete record using Prepared Statement in Java

PreparedStatement is an interface and has pre-compiled SQL statements. PreparedStatements are used to efficiently execute the same SQL statement multiple times. They are also used to set the parameters in query dynamically.

Steps to Delete record using Prepared Statement

1. Get a connection Object

2. Create a prepareStatement object

3. Add parameters (if required)

ParameterIndex starts from 1.

4. execute the query using executeUpdate.

Full Example : Delete record using Prepared Statement

Output

Reference

1. PreparedStatement API