【发布时间】:2016-01-09 21:10:15
【问题描述】:
所以我这里有这段代码:
try {
rs = stmt.executeQuery("SELECT * FROM systemaccount where ID = '"+getValue+"'");
while(rs.next())
{
fname.setText(rs.getString("First_Name"));
mname.setSelectedItem(rs.getObject("Middle_name"));
lname.setText(rs.getString("Last_Name"));
address.setText(rs.getString("address"));
contact.setText(rs.getString("Contact_Number"));
user.setText((String) getValue((Integer) rs.getObject("User"), "user"));
usertype.setSelectedItem(getValue((Integer) rs.getObject("user_type"), "user_type")); //<-----THE ERROR IS HERE
}
} catch (SQLException ex) {
Logger.getLogger(SystemAccount.class.getName()).log(Level.SEVERE, null, ex);
System.out.println(ex.getMessage());
}
所以基本上我的代码所做的是,当我双击jTable 时,它也会自动填充ComboBox 和TextFields。但是MySQL 会抛出一个错误,它没有找到任何user_type 列名。
正如您在下面看到的,我有证据证明它有一个名为 user_type 的列名。
systemaccount table having user_type column
我总是得到
java.sql.SQLException: Column 'user_type' not found. error on the line usertype.setSelectedItem(getValue((Integer) rs.getObject("user_type"), "user_type"));
关于发生了什么的任何提示?
【问题讨论】:
-
我想没有人知道解决方案。是什么原因造成的?以及如何解决?