Java SQL Table Drop dropTable(Connection con, String table)

Here you can find the source of dropTable(Connection con, String table)

Description

drop Table

License

Open Source License

Declaration

public static void dropTable(Connection con, String table) throws SQLException 

Method Source Code

//package com.java2s;
/*// ww  w. java2 s.  c o m
 * Copyright (c) 2004, PostgreSQL Global Development Group
 * See the LICENSE file in the project root for more information.
 */

import java.sql.Connection;

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

public class Main {
    public static void dropTable(Connection con, String table) throws SQLException {
        Statement stmt = con.createStatement();
        try {
            String sql = "DROP TABLE " + table + " CASCADE ";
            stmt.executeUpdate(sql);
        } catch (SQLException ex) {
            // Since every create table issues a drop table
            // it's easy to get a table doesn't exist error.
            // we want to ignore these, but if we're in a
            // transaction then we've got trouble
            if (!con.getAutoCommit()) {
                throw ex;
            }
        }
    }
}

Related

  1. delete(Connection conn, String table, Serializable id)
  2. deleteMySqlTable(String tableName, Statement stmt)
  3. deleteTable(Connection con, String tableName)
  4. dropTable(Connection con, String tableName)
  5. dropTable(Connection conn, String table)
  6. dropTable(Connection conn, String tablename)
  7. dropTable(Connection conn, String tableName)