import java.sql.*; public class CreateCoffees { public static void main(String args[]) { //This program assumes that the CafeJava database allready exists and creates //table called "coffee" in it. //This URL requires an ODBC link called CafeJava. String url = "jdbc:odbc:CafeJava"; Connection con; String createString; //The following String is the SQL statement needed to //create the table "coffees" createString = "create table COFFEES " + "(COF_NAME varchar(32), " + "SUP_ID int, " + "PRICE float, " + "SALES int, " + "TOTAL int)"; Statement stmt; try { //Load the JDBC-ODBC bridge driver. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch(java.lang.ClassNotFoundException e) { System.err.print("ClassNotFoundException: "); System.err.println(e.getMessage()); } try { //Open a connection to the database. con = DriverManager.getConnection(url, "Admin", "duke1"); //Create a statement. stmt = con.createStatement(); //Have the Statement execute the SQL statement defined above. //This creates the "coffee" table. stmt.executeUpdate(createString); stmt.close(); con.close(); } catch(SQLException ex) { System.err.println("SQLException: " + ex.getMessage()); } } }