一、查询所有学生记录,包含年级名称
1.创建实体学生类封装属性
public class IStudent {
IGrade grade=new IGrade();
public IGrade getGrade() {
return grade;
}
public void setGrade(IGrade grade) {
this.grade = grade;
}
private int StudentNo;
private String loginPwd;
private String StudentName;
private int Sex;
private int GradeId;
private String phone;
private String BornDate;
private String email;
private String IdentityCard;
private String address;
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public int getStudentNo() {
return StudentNo;
}
public void setStudentNo(int studentNo) {
StudentNo = studentNo;
}
public String getLoginPwd() {
return loginPwd;
}
public void setLoginPwd(String loginPwd) {
this.loginPwd = loginPwd;
}
public String getStudentName() {
return StudentName;
}
public void setStudentName(String studentName) {
StudentName = studentName;
}
public int getSex() {
return Sex;
}
public void setSex(int sex) {
Sex = sex;
}
public int getGradeId() {
return GradeId;
}
public void setGradeId(int gradeId) {
GradeId = gradeId;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getBornDate() {
return BornDate;
}
public void setBornDate(String bornDate) {
BornDate = bornDate;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getIdentityCard() {
return IdentityCard;
}
public void setIdentityCard(String identityCard) {
IdentityCard = identityCard;
}
public IStudent(int studentNo, String loginPwd, String studentName, int sex,
int gradeId, String phone, String bornDate, String email,
String identityCard) {
StudentNo = studentNo;
this.loginPwd = loginPwd;
StudentName = studentName;
Sex = sex;
GradeId = gradeId;
this.phone = phone;
BornDate = bornDate;
this.email = email;
IdentityCard = identityCard;
}
public IStudent() {
// TODO Auto-generated constructor stub
}
}
2.创建接口Dao层编写查询学生的方法
编写查询年级表的方法
3.创建工具类
4.实现接口Dao层并继承工具类
5.测试UI类
二、查询S1年级下的学生记录
1.创建Grade表实体类并创建学生实体类集合
2.在Dao层中编写方法
3.实现Dao接口
4.测试UI层