1、实现IStudentDAOImpl类中的updateStudentById()函数,代码如下:
![]()
@Override
public void updateStudentById(Student student) {
// TODO Auto-generated method stub
try {
sqlMapClient.update("updateStudentById", student);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
2、Student.xml 文件中添加如下代码:
![]()
<!-- parameterClass="Student" 可改为 parameterClass="student"说明不区分大小写 -->
<update id="updateStudentById" parameterClass="Student"> update student set sname=#sname#,major=#major#,birthent=#birth#,score=#score# where sid=#sid#</update>
3、main()调用:
![]()
public static void main(String[] agr0) throws Exception{
IStudentDAO dao = new IStudentDAOImpl();
Student stu = new Student();
stu.setSid(7);
stu.setSname("yyy");
stu.setMajor("fffff");
stu.setBirth(Date.valueOf("2013-10-14"));
stu.setScore(94);
dao.updateStudentById(stu);
}