我知道這是一個重複的問題。對不起,問。我在我的spring mvc應用程序中遇到這個錯誤。 這是我默認地將Impl文件引起:java.sql.SQLException:未找到列'localename'
public Map<String, String> employeelist() {
Map<String, String> map = new HashMap<String, String>();
List<Employee> lang1 = namedParameterJdbcTemplate.query("select * from
employee", new EmployeeMapper());
for (int i = 0; i < lang1.size(); i++) {
map.put(lang1.get(i).getLocalename(), lang1.get(i).getName());
}
return map;
}
public static final class EmployeeMapper implements RowMapper<Employee> {
public Employee mapRow(ResultSet rs, int rowNum) throws SQLException {
Map<String, String> map = new HashMap<String, String>();
Employee employee = new Employee();
employee.setId(rs.getString("id"));
employee.setName(rs.getString("name"));
employee.setSalary(rs.getString("salary"));
employee.setDesignation(rs.getString("designation"));
employee.setLocalename(rs.getString("localename"));
return employee;
}
}
在試圖執行此我得到了如下的錯誤"Caused by: java.sql.SQLException: Column 'localename' not found"
。所有其他字段正常工作。但對於localename只顯示其錯誤。這裏有什麼問題??請幫我..
對不起,我的英文不好
這是我的員工類
package com.bct.internal.form.model;
public class Employee {
private String id;
private String name;
private String salary;
private String designation;
private String localename;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSalary() {
return salary;
}
public void setSalary(String salary) {
this.salary = salary;
}
public String getDesignation() {
return designation;
}
public void setDesignation(String designation) {
this.designation = designation;
}
public String getLocalename() {
return localename;
}
public void setLocalename(String localename) {
this.localename = localename;
}
@Override
public String toString() {
return "Employee [ID=" + id + ", NAME=" + name + ", SALARY=" + salary +
", LOCALE_NAME=" + localename + ", DESIGNATION=" + designation + "]";
}
}
表'employee'是否有名爲'localename'的列?這顯然是首先要檢查錯誤消息是否說沒有這樣的列。 – Jesper
@Jesper是的,它是 – Shanmugapriya
@TanmayDelhikar ..當然tanmay ..我會編輯我的問題 – Shanmugapriya