
import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

     
public class CreateCoffeesMysql {

	public static void main(String args[]) {
		  
		String url = "jdbc:mysql://localhost/test?user=monty&password=greatsqldb";
		Connection con;
		String createString;
		createString = "create table COFFEES " +
							"(COF_NAME varchar(32), " +
							"SUP_ID int, " +
							"PRICE float, " +
							"SALES int, " +
							"TOTAL int)";
		Statement stmt;
        try {
            // The newInstance() call is a work around for some
            // broken Java implementations
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            } catch (Exception e) {
			System.err.print("ClassNotFoundException: "); 
			System.err.println(e.getMessage());
		                           }
        try {
			con =DriverManager.getConnection(url);
			stmt = con.createStatement();							
	   		stmt.executeUpdate(createString);
			stmt.close();
			con.close();
	
		} catch (SQLException ex) {
             // handle any errors
             System.out.println("SQLException: " + ex.getMessage());
             System.out.println("SQLState: " + ex.getSQLState());
             System.out.println("VendorError: " + ex.getErrorCode());
         }
	}
}

