/**** SuppliersAndPartsDropTables.java ****/ import java.sql.*; public class SuppliersAndPartsDropTables { public static void main(String[] args) { if (usageOnly(args)) return; String driver = "sun.jdbc.odbc.JdbcOdbcDriver"; if (args.length > 0) driver = args[0]; String url = "jdbc:odbc:SuppliersAndParts"; if (args.length > 1) url = args[1]; try { Class.forName(driver).newInstance(); Connection con = DriverManager.getConnection(url); System.out.println("Connected to: " + url); Statement stmt = con.createStatement(); stmt.execute("drop index SX"); stmt.execute("drop index PX"); stmt.execute("drop index JX"); stmt.execute("drop index SPX"); stmt.execute("drop index SPJX"); stmt.execute("drop table S"); stmt.execute("drop table P"); stmt.execute("drop table J"); stmt.execute("drop table SP"); stmt.execute("drop table SPJ"); stmt.close(); con.close(); } catch (SQLException ex) { System.out.println("\nSQLException...\n"); while (ex != null) { System.out.println("SQLState: " + ex.getSQLState()); System.out.println("Message: " + ex.getMessage()); System.out.println("Vendor: " + ex.getErrorCode()); ex = ex.getNextException(); System.out.println(""); } } catch (Exception ex) { ex.printStackTrace(); } } private static boolean usageOnly(String[] args) { if (args.length > 0) { if (args[0].equalsIgnoreCase("-help") || args[0].equalsIgnoreCase("-h") || args[0].equalsIgnoreCase("-usage") || args.length > 2) System.out.println( "Usage: java SuppliersAndPartsDropTables" + " [] []"); return true; } else return false; } } // SuppliersAndPartsDropTables class //