import java.sql.*;

public class CreateCoffees {
  
  public static void main( String args[] ) {

    String url = "jdbc:oracle:thin:@127.0.0.1:1521:orcl";
    Connection con;
    String createString;

    createString = 
    "CREATE TABLE coffees" + 
    "(cof_name VARCHAR(32), " + 
    "sup_id INTEGER, " + 
    "price FLOAT, " + 
    "sales INTEGER, " + 
    "total INTEGER, " +
    "primary key (cof_name))";

    Statement stmt;

    try {
      // 1.JDBC µå¶óÀÌ¹ö ·Îµù
      Class.forName( "oracle.jdbc.driver.OracleDriver" );
    } catch( java.lang.ClassNotFoundException e ) {
      System.err.print( "ClassNotFoundException: " );
      System.err.println( e.getMessage() );
    }

    try {
      // 2.Connection ¸Î±â
      con = DriverManager.getConnection( url, "scott", "tiger" );
      // 3.SQL ½ÇÇà
      stmt = con.createStatement();
      // 3.SQL ½ÇÇà
      stmt.executeUpdate( createString );
      // 5.ÀÚ¿ø ¹ÝÈ¯ ( Statement )
      stmt.close();
      // 5.ÀÚ¿ø ¹ÝÈ¯ ( Connection )
      con.close();
    } catch( SQLException ex ) {
      System.err.println( "SQLException: " + ex.getMessage() );
    }
  }
}
