0

I know this is a repeated question. Sorry for asking. I am having this error in my spring mvc application. This is my Impl file

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;
    }

}

While trying to execute this i am getting an error like "Caused by: java.sql.SQLException: Column 'localename' not found". All other fields are working correctly. But for localename only its showing the error. What is the problem here?? Please help me..

Sorry for my poor english

This is my employee class

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 + "]";
}
}
Shanmugapriya
  • 57
  • 3
  • 15

3 Answers3

0

Please check

SELECT * FROM Employee 

or

DESC Employee

The column name localename is present or not in the table. Also check the datatype of the localename.

Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
Arvind Katte
  • 995
  • 2
  • 10
  • 20
0

You should connect to your database and execute (be sure to be in the correct schema):

DESC employee;

You need to be 100% sure that the name of the column 'localename' returned on the table description matches exactly, it should not have underscores or hyphens. This could just be a typo on the table you created.

0

if the column name localename is not present in the table then add the column localname, then check column localname is mapped or not in hbm file(if using hibernate).

Vikas
  • 490
  • 4
  • 10