@Autowired
private JdbcTemplate jdbcTemplate;
public User findUserById(Integer userId) {
User user = null;
user = jdbcTemplate.queryForObject("select * from user where user_id=?", new Object[]{userId}, new RowMapper<User>(){
@Override
public User mapRow(ResultSet rs, int rowNum) throws SQLException {
User user = new User();
user.setUserId(rs.getInt("user_id"));
user.setUserName(rs.getString("username"));
return user;
}});
return user;
}