خرید بک لینک

i want to add a new column to my database with java , i use eclipse

i put the the UI in a class and the activity in other class
this is the code

Code:

public class Emp {
    private Coection con;
    private int EMPNO;
    private String ENAME;
    private String JOB;
    private int SAL;
    private String EMAIL_EMP;
    public int getEMPno() {
        retu EMPNO;
    }
    public void setEMPno(int eMPno) {
        EMPNO = eMPno;
    }
    public String getENAME() {
        retu ENAME;
    }
    public void setENAME(String eNAME) {
        ENAME = eNAME;
    }
    public String getJOB() {
        retu JOB;
    }
    public void setJOB(String jOB) {
        JOB = jOB;
    }
    public int getSAL() {
        retu SAL;
    }
    public void setSAL(int sAL) {
        SAL = sAL;
    }
    public String getEMAIL_EMP() {
        retu EMAIL_EMP;
    }
    public void setEMAIL_EMP(String eMAIL_EMP) {
        EMAIL_EMP = eMAIL_EMP;
    }
    public Emp(int eMPno, String eNAME, String jOB, int sAL, String eMAIL_EMP) {
        super();
        EMPNO = eMPno;
        ENAME = eNAME;
        JOB = jOB;
        SAL = sAL;
        EMAIL_EMP = eMAIL_EMP;
    }
    public Emp() {
        super();
    }
    
    
    public void addemp(int EMPNO, String ENAME, String JOB, int SAL,String EMAIL_EMP) throws SQLException {
        String requette = "INSERT INTO `emp` (`EMPNO` ,`ENAME` ,`JOB` ,`SAL`,`EMAIL_EMP`)" +
                "VALUES (?, ?, ?, ?,?)";
        PreparedStatement ps = con.prepareStatement(requette);
        ps.setInt(1, EMPNO);
        ps.setString(2, ENAME);
        ps.setString(3, JOB);
        ps.setInt(4, SAL);
        ps.setString(5, EMAIL_EMP);
        ps.executeUpdate();
    }
and the other class

Code:

JButton btnAdd = new JButton("add");
        btnAdd.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                
            
            try {
                Coect c=new Coect();
                c.coexionBD();
                Emp a=new Emp();
                a.addemp(Integer.parseInt(txtno.getText()), txtname.getText(), txtjob.getText(),Integer.parseInt(txtsal.getText()), txtemail.getText());
            } catch (SQLException e) {
                // 
                
            }
            
            }
        }

help me please and thanks

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 5 فروردين 1395 ساعت: 8:23

صفحه بندی