简体   繁体   中英

java.sql.sqlException:no such column: employID

Here is my code I am getting the following error" java.sql.sqlException :no such column: employID" and I have rechecked my db table column name is correct employID nothing wrong with that but still getting the same error please help I am trying to load the table data based on the first column into a textboxes using netbeans IDE and sqlite database.

private void tableEmployeeMouseClicked(java.awt.event.MouseEvent evt) {                                           
    try{ 
    int row=tableEmployee.getSelectedRow();
     String tableClick=(tableEmployee.getModel().getValueAt(row, 0).toString());
     String sql="SELECT * FROM employeeInfo WHERE employID=' "+tableClick+" ' ";

     pst=conn.prepareStatement(sql);
     rs=pst.executeQuery();
     if(rs.next()){
         String add1=rs.getString("employID");
         empid.setText(add1);
         String bdd=rs.getString("name");
         name.setText(bdd);
         String cdd=rs.getString("surname");
         surname.setText(cdd);
         String ddd=rs.getString("age");
         age.setText(ddd);     
     }         
     }
    catch(Exception e){
        JOptionPane.showMessageDialog(null,e);
    }

nb the employID column in my database is set to INTEGER can that or my query inside my code have any connection with the error type.. Thanks.

EDIT: The DDL sentence

CREATE TABLE "employeeInfo" (
"employID " INTEGER PRIMARY KEY NOT NULL , 
"name" CHAR, "surname" CHAR, 
"age" INTEGER, "username" VARCHAR, "password" VARCHAR)

From the error it is clear that the resultset does not have the column named 'employID'. To troubleshoot this issue you can do either of these: 1. Inspect the resultset metadata and look at the column names that you are getting. 2. Or use column position in resultset.getString() methods to get the values and verify if you are getting employID values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM