1

I'm trying to get single row from Oracle DB by using RowMapper in Spring, but I'm getting the following exception:

Exception in thread "main java.lang.NoClassDefFoundError:
org/springframework/dao/DuplicateKeyException

Can anyone explain me the reason for that exception?


Below is my code:

public class EmployeeRowMapper implements RowMapper{

    public Object mapRow(ResultSet rs,int rowNmu) throws SQLException {
        Employee e = new Employee();
        e.seteId(rs.getInt("ID"));
        e.seteName(rs.getString("name"));
        e.seteSal(rs.getFloat("sal"));

        return e;
    }
}

Here is how I try to retrie a row:

public Employee getEmpById(int id) {

    String sql = "select * from emp where ENO = ?";
    @SuppressWarnings("unchecked")
    Employee e = (Employee)jt.queryForObject(sql,new Object[] {id}, new EmployeeRowMapper());

    return e;
}
informatik01
  • 16,038
  • 10
  • 74
  • 104
  • 1
    Can you add the full stack trace please? – Taylor Oct 09 '16 at 14:52
  • Show your dependencies, you are probably missing a needed dependency. Use something like maven or gradle to manage your dependencies instead of doing manual management (which I suspect you are using). – M. Deinum May 29 '19 at 11:53

0 Answers0