import java.awt.*; import java.awt.event.*; import java.util.*; import java.sql.*; public class Test1 extends Frame implements ActionListener { public Button but_exit; public Button but_sql; Test1() { // initial layout of frame setLayout(null); setBackground(Color.gray); setForeground(Color.black); setTitle("Test1ing"); // instantiate but_exit = new Button("Exit"); but_sql = new Button("Execute SQL"); // add components to frame this.add(but_exit); this.add(but_sql); // actionlistener but_exit.addActionListener(this); but_sql.addActionListener(this); // bounds this.setBounds(0,0,800,600); but_sql.setBounds (380,460,150,20); but_exit.setBounds(380,560,50,20); // focus this.requestFocus(); }// end of constructor public static void main(String[] args) { Test1 tst = new Test11(); tst.show(); }// end of main public void actionPerformed(ActionEvent e) { if (e.getSource() == but_exit) { System.exit(0); } // but_exit if (e.getSource() == but_sql) { try { int x = 40; int y = 40; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:oracle8","scott","tiger"); Statement stmt = con.creaTest11atement(); ResultSet rs = stmt.executeQuery("select empno from emp"); while (rs.next()) { System.out.println( rs.getInt(1) ); y=y+25; } } catch(Exception er) { System.out.println("Error - " + er); } } // but_sql } public void paint(Graphics g) { String s = "Hey guys, this is my first Test11 program in Java !!!"; g.drawString(s,10,40); } }// end of class