Code example for ResultSet

Methods: getDouble, getInt, getLong, getString, getTimestamp

0
import java.sql.Timestamp; 
 
public class ThesisUniqueMapper implements ParameterizedRowMapper<ThesisUnique> { 
    public ThesisUnique mapRow(ResultSet resultSet, int i) {
        try { 
            return new ThesisUnique(resultSet.getLong("id"), resultSet.getString("content"),
                                    resultSet.getInt("frequency"), resultSet.getTimestamp("last_scan"),
                                    resultSet.getDouble("positivity"), resultSet.getDouble("importance"));
        } catch (SQLException e) {
            // Something is wrong with the base, i.e. one of column labels isn't presented. 
            return new ThesisUnique(-1, "NOCONTENT", 0, new Timestamp(System.currentTimeMillis()), 0.0, 0.0);
        } 
    } 
}