JDBC Using Prepared Statement example–Delete all record
/* This program shows you how to delete all rows from
the database table using JDBC PreparedStatement.*/
package r4r;
import java.sql.*;
public class DeleteAllData
{
public static void main(String[] args) {
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection
("jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
PreparedStatement stmt=con.prepareStatement("delete from user5");
stmt.executeQuery();
System.out.println("successfully deleted");
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
output: