public class User {
private int id;
private String name;
private String gender;
private int age;
private String address;
private String qq;
private String email;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getQq() {
return qq;
}
public void setQq(String qq) {
this.qq = qq;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public interface ServiceUser {
List<User> findAll();
}
public class ServiceUserImpl implements ServiceUser {
@Override
public List<User> findAll() {
List<User> users = new UserDaoImpl().findAll();
return users;
}
}
public interface UserDao {
List<User> findAll();
}
public class UserDaoImpl implements UserDao {
private JdbcTemplate template=new JdbcTemplate(JDBCUtils.getDataSource());
@Override
public List<User> findAll() {
String sql="select * from user";
List<User> list = template.query(sql, new BeanPropertyRowMapper<User>(User.class));
return list;
}
}