public List queryRowMapper(){
final String sql="select *from users";
final List result = new ArrayList();
result.clear();
jdbcTemplate.query(new PreparedStatementCreator(){
@Override
public PreparedStatement createPreparedStatement(Connection conn)
throws SQLException {
// TODO Auto-generated method stub
return conn.prepareStatement(sql);
}
}, new RowMapper(){
@Override
public Object mapRow(ResultSet rs, int arg1) throws SQLException {
// TODO Auto-generated method stub
Map row = new HashMap();
row.put(rs.getInt("id"), rs.getString("name"));
return row;
}
});
return result;
}
final String sql="select *from users";
final List result = new ArrayList();
result.clear();
jdbcTemplate.query(new PreparedStatementCreator(){
@Override
public PreparedStatement createPreparedStatement(Connection conn)
throws SQLException {
// TODO Auto-generated method stub
return conn.prepareStatement(sql);
}
}, new RowMapper(){
@Override
public Object mapRow(ResultSet rs, int arg1) throws SQLException {
// TODO Auto-generated method stub
Map row = new HashMap();
row.put(rs.getInt("id"), rs.getString("name"));
return row;
}
});
return result;
}