import java.net.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;

public class jdbccreatetable extends Frame 
{  
    Choice students;
    Choice grades;   
    Connection connection;
    Statement statement, statement2;

    public jdbccreatetable()
    {  
        students = new Choice();
        grades = new Choice();
      
        setLayout(new FlowLayout());

        try 
        {  
             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
           
             connection = DriverManager.getConnection(
                 "jdbc:odbc:students", "Steve", "password");

             statement = connection.createStatement();         

             String[] SQLStatements = {
             "CREATE TABLE students2 (Name char(25), Grade char(25))",
             "INSERT INTO students2 VALUES('Jennifer', 'B')",
             "INSERT INTO students2 VALUES('Mark', 'A')",
             "INSERT INTO students2 VALUES('Carol', 'C')",
             "INSERT INTO students2 VALUES('Samuel', 'A')"};

             for(int loop_index = 0; loop_index < SQLStatements.length; loop_index++) {
                 statement.executeUpdate(SQLStatements[loop_index]);
             }
         
             statement2 = connection.createStatement();         

             String SQL = "SELECT Name FROM students2";
        
             ResultSet resultset = statement2.executeQuery(SQL);
             while (resultset.next()) 
                 students.addItem(resultset.getString(1));

             SQL = "SELECT Grade FROM students2"; 
             resultset = statement2.executeQuery(SQL);
             while (resultset.next()) 
                 grades.addItem(resultset.getString(1));
      }
      catch(Exception e) {System.err.println(e);}  

      add(students);
      add(grades);
   }

   public static void main (String args[]) 
   {  
       Frame f = new jdbccreatetable();

       f.setSize(300, 300);

       f.addWindowListener(new WindowAdapter() {public void
           windowClosing(WindowEvent e) {System.exit(0);}});

       f.show();
   }
}
