Java SQL Table Drop delete(Connection conn, String table, Serializable id)

Here you can find the source of delete(Connection conn, String table, Serializable id)

Description

delete

License

Open Source License

Declaration

public static boolean delete(Connection conn, String table, Serializable id) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.Serializable;

import java.sql.Connection;

import java.sql.SQLException;
import java.sql.Statement;

public class Main {

    public static boolean delete(Connection conn, String table, Serializable id) {
        int ret = 0;
        try {// w w  w . j a  va 2 s  . c om
            Statement statement = conn.createStatement();
            String sql = String.format("DELETE FROM %s WHERE id = %s;", table, id);
            ret = statement.executeUpdate(sql);
            statement.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return ret != 0;
    }
}

Related

  1. deleteMySqlTable(String tableName, Statement stmt)
  2. deleteTable(Connection con, String tableName)
  3. dropTable(Connection con, String table)
  4. dropTable(Connection con, String tableName)