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

  1.  
  2. import java.net.URL;
  3. import java.sql.*;
  4.      
  5. public class CreateSuppliers {
  6.  
  7.     public static void main(String args[]) {
  8.         String url = "jdbc:odbc:CafeJava";
  9.         Connection con;
  10.         String createString;
  11.         createString = "create table SUPPLIERS " + 
  12.                         "(SUP_ID int, " +
  13.                         "SUP_NAME varchar(40), " +
  14.                         "STREET varchar(40), " +
  15.                         "CITY varchar(20), " +
  16.                         "STATE char(2), ZIP char(5))";
  17.     
  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.