0

i' ve a code snippet like below. but it gives error at list.add(mapper.mapRow()); line says "The method add(K) in the type List is not applicable for the arguments (Object)". how can i fix it?

thanks.

    public List<K>  fetchData(JStarRowMapper mapper) {
    List<K> list = new ArrayList<K>();
    list.add(mapper.mapRow());
    return list;
}




public class IncomingRowMapper<K> implements JStarRowMapper {
@Override
public IncomingVO mapRow(ResultSet rs) throws SQLException {

    IncomingVO vo = new IncomingVO();
    vo.setId(rs.getInt("id"));
    vo.setUsername(rs.getString("username"));
    vo.setProcessDate(rs.getTimestamp("process_date"));
    vo.setProcessCount(rs.getInt("process_count"));
    return vo;
}

}

public interface JStarRowMapper<K> {
abstract public K mapRow(ResultSet rs) throws SQLException;

}

0

2 Answers 2

2

In the first snippet you should declare mapper as

JStarRowMapper<K>

Also mapRow is called without parameters, whereas it needs a ResultSet parameter

Sign up to request clarification or add additional context in comments.

Comments

0

Another problem is that IncomingRowMapper should be declared as:

public class IncomingRowMapper implements JStarRowMapper<IncomingVO> { ...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.