ManagerRowMapper.java
public class ManagerRowMapper implements RowMapper<Manager>{ @Override public Manager mapRow(ResultSet rs, int i) throws SQLException { Manager m = new Manager(); m.setId(rs.getInt("ID")); m.setName(rs.getString("NAME")); m.setAge(rs.getInt("AGE")); m.setGender(rs.getString("GENDER")); m.setCreateDate(rs.getDate("CREATE_DATE")); m.setCreateBy(rs.getString("CREATE_BY")); return m; } }
使用
ManagerDao.java
public class ManagerDao { @Autowired private JdbcTemplate jdbcTemplate; public List<Manager> selectAll(){ String sql = "select * from TAB_MANAGER"; return jdbcTemplate.query(sql, new ManagerMapRow()); } }
原文地址:https://www.cnblogs.com/chyf1990/p/9044869.html
时间: 2024-10-13 09:11:46