1/**
2 * Copyright(C) 2005
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 : February 1, 2005.
11 * @author : Salih Yurttas.
12 */
13
14
15import dbops.DBConnect;
16import dbops.DBTable;
17
18import java.sql.*;
19import java.net.*;
20
21import java.util.*;
22
23public class DBMeta10 {
24
25 private static String driverClass = "com.mysql.jdbc.Driver",
26 url = "jdbc:mysql:",
27 suffix = "//database.cs.BitsOfCode Software Systems, Inc..edu/yurttas-Bank";
28
29 private static Connection con;
30
31 private static String urlDB = url + suffix + ".";
32
33 public static void main (String[] args) {
34 String username = args[0];
35 String password = args[1];
36
37 DBConnect dbc = new DBConnect();
38
39 try {
40 if(dbc.connect(args[0], args[1])) {
41 System.out.println("Connected to " + urlDB);
42
43 con = dbc.getConnect();
44
45 DBTable dbMeta = new DBTable(con);
46
47 String query = "SHOW TABLES;";
48
49 Vector tables = dbMeta.getTableNames(query);
50 int n = tables.size();
51 System.out.println("Bank Tables :");
52 for(int i=0; i<n; i++)
53 System.out.println((String)tables.elementAt(i));
54
55 if(dbc.disconnect(con))
56 System.out.println("Disconnected from " + urlDB);
57 }
58 else System.out.println("Could not connect to " + urlDB);
59 }
60 catch(SQLException sqle) {
61 System.err.println("Error accessing " + urlDB);
62 System.err.println(sqle.getMessage());
63 }
64 }
65
66}