使用jdbc将mysql数据库中的内容封装为指定对象的list集合

public List<User> findAll() {
    private JdbcTemplate template = new JdbcTemplate(JdbcUtils.getDataSourse());
    //使用jdbc操作数据库
    //1.定义sql语句
    String sql = "select * from user";
    //2.执行sql语句
    List<User> users = template.query(sql, new BeanPropertyRowMapper<User>(User.class));
        return users;
    }
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄