Announcement Announcement Module
Collapse
No announcement yet.
RowMapper.mapRow error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • RowMapper.mapRow error

    Hello, I'm trying to use JdbcTemplate to get a Person from my DB.

    I'm following the example from:

    http://static.springframework.org/sp...plate-examples

    which suggests to use a static inner class to avoid code dupplication. I getting this error from Eclipse:

    "the type PersonDAOImpl.PersonaMapper must implement the inherited abstract method
    RowMapper.mapRow(ResultSet,int)"

    I get this problem even if I dont use the inner class. Heres my code:

    Code:
    package dao;
    
    import java.sql.SQLException;
    import org.springframework.jdbc.core.JdbcTemplate;
    import org.springframework.jdbc.core.RowMapper;
    import com.mysql.jdbc.ResultSet;
    import javax.sql.DataSource;
    import beans.Persona;
    
    public class PersonDAOimpl implements PersonDAO {
    	
    	private JdbcTemplate jdbcTemplate;
    	
    	public void setJdbcTemplate(JdbcTemplate jdbctemplate){
    		this.jdbcTemplate = jdbcTemplate;
    	}
    	
    		
    	public boolean validarRegistro(String rut, String dv, String clave){
    		
    		String sql = "SELECT * FROM Persona WHERE rut = ? and dv = ? and clave=?";
    		Persona persona=null;
    		
    		persona = (Persona) this.jdbcTemplate.queryForObject(sql,
    				new Object[]{rut,dv,clave}, new PersonaMapper()); 
    		     
    		if(persona!=null)
    			return true;
    		else
    			return false;
    		
    	}
    	
    	private static final class PersonaMapper implements RowMapper {
    
    	public Object mapRow(ResultSet rs, int rowNum)
    			throws SQLException {
    		 Persona persona = new Persona();
    	        persona.setRut(rs.getString("rut"));
    	        persona.setDv(rs.getString("dv"));
    	        persona.setClave(rs.getString("clave"));
    		return persona;
    	}
    
    			
    	}
    	
    }
    Any help will be appreciated!
    Thanks!

  • #2
    It looks like you're referencing the wrong type for ResultSet in your example:

    Code:
    import com.mysql.jdbc.ResultSet;
    Instead, this should be:

    Code:
    import java.sql.ResultSet;

    Comment


    • #3
      Thank you!!!!!!!

      Comment

      Working...
      X