home *** CD-ROM | disk | FTP | other *** search
/ PC World 1998 October / PCWorld_1998-10_cd.bin / software / prehled / inprise / JSAMPLES.Z / CreateCoffees.java < prev    next >
Text File  |  1998-05-08  |  911b  |  45 lines

  1.  
  2. import java.sql.*;
  3.      
  4. // Create the Coffee Table.
  5. public class CreateCoffees {
  6.  
  7.     public static void main(String args[]) {          
  8.           
  9.         String url = "jdbc:odbc:CafeJava";
  10.         Connection con;
  11.         String createString;
  12.         createString = "create table COFFEES " +
  13.                             "(COF_NAME varchar(32), " +
  14.                             "SUP_ID int, " +
  15.                             "PRICE float, " +
  16.                             "SALES int, " +
  17.                             "TOTAL int)";
  18.         Statement stmt;
  19.     
  20.         try {
  21.             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  22.  
  23.         } catch(java.lang.ClassNotFoundException e) {
  24.             System.err.print("ClassNotFoundException: "); 
  25.             System.err.println(e.getMessage());
  26.         }
  27.  
  28.         try {
  29.             con = DriverManager.getConnection(url, 
  30.                                      "Admin", "duke1");
  31.     
  32.             stmt = con.createStatement();                            
  33.                    stmt.executeUpdate(createString);
  34.     
  35.             stmt.close();
  36.             con.close();
  37.     
  38.         } catch(SQLException ex) {
  39.             System.err.println("SQLException: " + ex.getMessage());
  40.         }
  41.  
  42.     }
  43. }
  44.  
  45.