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

public class jdbcmetadata extends Frame 
{  
    TextArea textarea;
    Connection connection;
    Statement statement;

    public jdbcmetadata()
    {  
        textarea = new TextArea(5, 30);
      
        setLayout(new FlowLayout());

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

             statement = connection.createStatement();         
         
             String SQL = "SELECT Name, Grade FROM Students"; 
             ResultSet resultset = statement.executeQuery(SQL);

             ResultSetMetaData resultsetmetadata = resultset.getMetaData();

             int nCols = resultsetmetadata.getColumnCount();

             String data = "";
             
             for (int nColumn = 1; nColumn <= nCols; nColumn++) {
                 data += resultsetmetadata.getColumnName(nColumn) + " ";
                 data += resultsetmetadata.getColumnLabel(nColumn) + " ";
                 data += resultsetmetadata.getColumnDisplaySize(nColumn) + " ";
                 data += resultsetmetadata.getColumnTypeName(nColumn) + "\n";
             }

             textarea.insert(data, 0);
      }
      catch(Exception e) {}  

      add(textarea);
   }

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

       f.setSize(300, 300);

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

       f.show();
   }
   
}
