import java.sql.*;
import java.awt.*;
import java.awt.event.*;


class  FDB extends Frame implements ActionListener
{
	TextField tf1;
	TextField tf2;
	Button save;
	Button exit;
	String s1;
	String s2;
	String ss;


	public FDB()
		{
		super("mezo notepad2");
		this.setSize(500,400);
		this.setLayout(null);

		tf1 = new TextField();
		tf1.setBounds(30,50,250,20);
		this.add(tf1);

		tf2 = new TextField();
		tf2.setBounds(30,90,250,20);
		this.add(tf2);



		save = new Button("save");
		save.setBounds(100,130,40,20);
		save.addActionListener(this);
		this.add(save);



		exit = new Button("exit");
		exit.setBounds(180,130,40,20);
		exit.addActionListener(this);
		this.add(exit);



		this.setVisible(true);

		}

		public void actionPerformed( ActionEvent e){
		ss = e.getActionCommand();

		if (ss.equals( "exit"))
		{
			System.exit(0);
		}

		if (ss.equals( "save"))
		{

			try
			{

				s1 = tf1.getText();
				s2 = tf2.getText();
				Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
				Connection con = DriverManager.getConnection("jdbc:odbc:thisdb");
				Statement stmt = con.createStatement();
				int result2 = stmt.executeUpdate("INSERT INTO Table1 (nam, seat) VALUES ('" + s1 +"','"+s2+"')");
				stmt.close();
			con.close();
							
			}
			catch (Exception ee)
		{
			ee.printStackTrace(System.out);
		}
		}


		}

	public static void main(String[] args) 
	{
		FDB f = new FDB();
	}
}
