[英]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. 这是我的代码,我收到以下错误“ java.sql.sqlException
:no such column:employeeID”,并且我重新检查了我的数据库表列名称是否正确, employID
没什么错,但是仍然出现相同的错误,请帮助我尝试使用netbeans IDE和sqlite数据库将基于第一列的表数据加载到文本框中。
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. nb我数据库中的employID
列设置为INTEGER
可以使我或代码中的查询与错误类型有任何联系。。谢谢。
EDIT: The DDL sentence 编辑:DDL句子
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'. 从错误中可以明显看出,结果集没有名为“ 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. 要解决此问题,您可以执行以下任一操作:1.检查结果集元数据,然后查看要获取的列名。 2. Or use column position in resultset.getString() methods to get the values and verify if you are getting employID values. 2.或者在resultset.getString()方法中使用列位置来获取值,并验证您是否正在获取employeeID值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.