DELETE data in a table in Java

Description

The following code shows how to dELETE data in a table.

Example


    /*from w  w w  .  j  a va 2s.c  o  m*/


import java.sql.Connection;
import java.sql.PreparedStatement;

public class Main {
  public static void main(String[] argv) throws Exception {
    Connection con = null;
    PreparedStatement prepstmt;
    prepstmt = con.prepareStatement("DELETE FROM tCust " + " WHERE custId = ?");

    prepstmt.setString(1, "1");
    prepstmt.executeUpdate();

    prepstmt.close();
    con.close();
  }
}




















Home »
  Java Tutorial »
    JDBC »




Batch
Binary Data
Database
Date Time
Insert
ResultSet
SQL
Statement
Stored Function
Table