= ?";List employees = jdbcTemplate.query(sql, 18, new EmployeeRowMapper());public class EmployeeRowMapper implements RowMapper {@Overridepublic Employee mapRow(ResultSet rs, int rowNum) throws SQLException {Employee employee = new Employee();employee.setName(rs.getString("name"));employee.setAge(rs.getString("age"));return employee;}}Problem: what if I only care for the output that I'd be given if I execute the sql in any common sql tool? There the output would be:name;agejohn;18doh;22...As I know my sql, I know that I'd be getting back 2..." />

How to get a csv list from JdbcTemplate?

I have the following sql query and would like to use it with JdbcTemplate from spring:

String sql = "SELECT name, age FROM EMPLOYEE WHERE age >= ?";

List employees = jdbcTemplate.query(sql, 18, new EmployeeRowMapper());

public class EmployeeRowMapper implements RowMapper {

@Override

public Employee mapRow(ResultSet rs, int rowNum) throws SQLException {

Employee employee = new Employee();

employee.setName(rs.getString("name"));

employee.setAge(rs.getString("age"));

return employee;

}

}

Problem: what if I only care for the output that I'd be given if I execute the sql in any common sql tool? There the output would be:

name;age

john;18

doh;22

...

As I know my sql, I know that I'd be getting back 2...

Read More »

By: StackOverFlow - Tuesday, 13 March

Related Posts