0

So I'm making a data base as part of a school project, but I want the data to be able to be pulled through different buttons and didn't want to have to have a big long code for each button, so I tried making a method in another class and I can't get it to work

public class DataGather extends HRDatabase {
public void getData(){
try{
        String ID = iDSearch.getText();
        String Query = ("Select * From employee where ID like " +  (ID)) ;
        PreparedStatement pst = con.prepareStatement(Query);
        ResultSet rs=pst.executeQuery();
        String rsID = rs.getString("ID");
        String rsName = rs.getString("name");
        String rsSurname  = rs.getString("surname");
        String rsAge = rs.getString("age");
        String rsHomephone = rs.getString("homephone");
        String rsMobile = rs.getString("mobile");
        String rsAddress = rs.getString("address");
        String rsSalary = rs.getString("salary");
        String rsGrade = rs.getString("grade");
        String rsCompanyCar = rs.getString("companycarID");
        String rsParkingArea = rs.getString("parkingarea");
        String rsCommission = rs.getString("commission");
        String rsSalesVolume = rs.getString("salesvolume");
        String rsSoftware = rs.getString("softwaresetID");
        nameTextField.setText(rsName);
        iDTextField.setText(rsID);
        surnameTextField.setText(rsSurname);
        ageTextField.setText(rsAge);
        contactNumberTextField.setText(rsHomephone);
        addressTextField.setText(rsAddress);
        salaryTextField.setText(rsSalary);
        gradeTextField.setText(rsGrade);

        }catch(Exception e)
    {
        JOptionPane.showMessageDialog(null, e);
    }
    }

The above is the method

btnEditEmployee.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            //getData()  
        }
    });

I've tried a few methods, but nothing has worked, any help would be appreciated

0 Answers0