增加和更新:比如增加或更新一个学生(Student),参数类型是Student,返回值是可有可无(void 或object类型)。
删除:比如删除一个学生,参数类型是定义类型(Student)的属性(sid 或sname),返回值可有可无((void 或object类型)
查询:
1.查询单个学生:比如通过用户名查询单个学生信息,参数类型是定义类型(Student)的属性(sid 或sname),返回值是定义的类型(Student)
2.查询所有学生:比如通过用户名查询所有学生信息,参数类型是定义类型(Student)的属性(sname),返回值是定义类型的集合(List<Student>)
项目实例:
// 查询所有学生信息
List<Student> findAll() throws SQLException;
// 增加学生信息
void addStudent(Student student)throws SQLException;
// 删除学生信息
void deleteStudent(int sid)throws SQLException;
// 更新学生信息
void updateStudent(Student student)throws SQLException;
// 通过sid查询学生信息
Student findById(int sid)throws SQLException;
// 根据姓名模糊查询或性别,或者两者都有
List<Student> searchStudent(String sname,String gender)throws SQLException;
// 分页查询
List<Student> findPage(int currentPage) throws SQLException;
// 查询总记录数
int findCount()throws SQLException;
总结:增删改一般没有返回值类型,增删改的参数列表根据情况而定,比如添加一个学生,那么添加的参数列表就是自定义学生参数。比如删除一个学生,可以根据学生的id或者name进行删除,那么删除的参数列表就是int id或者String name。
比如修改学生,那么修改学生的参数列表就是自定义学生的参数。
查询一般有返回值,返回值的类型就是自定义的学生对象student,查询的参数列表是根据情况而定,比如根据姓名或性别进行查询。