// A simple Java application that illustrates the use of
// DriverManager, Driver, Connection, Statement and ResultSet

import java.sql.*;

public class Example {

  Connection con;

  public static void main (String arg[])
  {
    Example ex = new Example();
    ex.initdb();
    ex.testdb();
  }

  public void initdb()
  {
                String driverName;
                String url = "jdbc:odbc:prog";
                Connection con;
		try {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		} catch(java.lang.ClassNotFoundException e) {
			System.err.print("ClassNotFoundException: ");
			System.err.println(e.getMessage());
		}

		try {
      con = DriverManager.getConnection(url,"Login", "Password");
        } catch(SQLException ex)
        {System.err.println("SQLException: " + ex.getMessage());}
  }

  // Simple method to test the Customer class methods
  public void testdb () {
    String custID = null;
    Customer cust = new Customer(con);
    try {
      // Now insert a new Customer
      custID = cust.insertNewCustomer(
        "Jones", "Bill", "555-1234", "5 Main Street", "01234");
    } catch (SQLException e) {

      System.err.println ("Insert failed:");
      System.err.println (e.getMessage());
      System.exit (3);
    }

    try {
      // Read it back from the database
      CustomerInfo info = cust.getCustomer (custID);

    } catch (SQLException e) {

      System.err.println ("Read failed:");
      System.err.println (e.getMessage());
      System.exit (4);
    }
  }
}
