Yurttas/PL/DBL/mssql/F/04/00/01/DBDrop10.java

From ZCubes Wiki
Revision as of 10:26, 3 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="java" line start="1" enclose="div">/** * Copyright(C) 2004 * All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc.. * * P...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
 1/**
 2 *  Copyright(C) 2004
 3 *  All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4 *
 5 *  Permission to use, copy, modify, and distribute this
 6 *  software and its documentation for EDUCATIONAL purposes
 7 *  and without fee is hereby granted provided that this
 8 *  copyright notice appears in all copies.
 9 *
10 *  @date   : January 1, 2004.
11 *  @author : Salih Yurttas.
12 */
13
14
15import dbops.DBConnect;
16import dbops.DBTable;
17
18import java.sql.*;
19import java.net.*;
20
21public class DBDrop10 {
22
23  private static String driverClass = "com.mysql.jdbc.Driver",
24                        url         = "jdbc:mysql:",
25                        suffix      = "//localhost/bank";
26
27  private static Connection con;
28
29  private static String urlDB = url + suffix + ".";
30
31  public static void main (String[] args) {
32    String username = args[0];
33    String password = args[1];
34
35    DBConnect dbc = new DBConnect();
36
37    try {
38      if(dbc.connect(args[0], args[1])) {
39        System.out.println("Connected to " + urlDB);
40
41        con = dbc.getConnect();
42
43        DBTable dbDrop = new DBTable(con);
44
45        String dropTable = "DROP TABLE AA;";
46
47        if(dbDrop.setStatement(dropTable))
48          System.out.println("Table AA is dropped from " + urlDB);
49        if(dbc.disconnect(con)) 
50          System.out.println("Disconnected from " + urlDB);
51      }
52      else System.out.println("Could not connect to " + urlDB);
53    }
54    catch(SQLException sqle) {
55      System.err.println("Error accessing " + urlDB);
56      System.err.println(sqle.getMessage());
57    }
58  }
59
60}