jdbc/swing
============
Following is my code to retrive data from my ms-access table NAME to display the employee name and his id.
But iam getting the error as
can not resolve the symbol varaible addbutton
in the line (e.getSource == addbutton)
also can not resolve symbol
variable rs ( which is my Resultset that i have created in my code).
can any body help in solving my problem to retrieve and display the values from the table to the textfields.
Thanks in advance.
code starts:
========================================
import java.sql.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class sample1 extends JFrame implements ActionListener
{
public sample1()
{
super("Sample application");
// JPanel p = new JPanel();
JLabel empid = new JLabel("Employee id");
JLabel empnamelabel = new JLabel("Employee name");
JTextField id = new JTextField(20);
JTextField empname = new JTextField(20);
JButton addbutton = new JButton("Add");
Container c = getContentPane();
// c.add(p);
c.add(addbutton);
c.add(empnamelabel);
c.add(empname);
c.add(id);
c.add(empid);
addbutton.addActionListener( new ActionListener);
add( addbutton );
//load the JDBC-ODBC bridge driver
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
// Get the connection
Connection conn = DriverManager.getConnection("jdbc

dbc:empdsn");
// create a statement object, resultset object and prepared statement to pass sql queries.
Statement st = conn.createStatement();
st.executeQuery("Select * from NAME");
ResultSet rs = st.getResultSet();
pack();
setVisible(true);
}
public static void main(String args[])
{
sample1 sam = new sample1(sam);
sam.addWindowListener(
new WindowAdapter() {
public void windowClosing( WindowEvent e ) {
System.exit( 0 );
}
}
);
}
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==addbutton) {
try
{
while(rs.next())
{
id.setText(rs.getString(1));
empname.setText(rs.getString(2));
}
}
catch(Exception ee) {}
}
}
}