1. 配置相应的映射文件内容

 <delete id="deleteStudent" parameterClass="int">

   delete from student where sid=#sid#

  </delete>

2. 实现类的方法

public void deleteStudentById(int id) {

try {

sqlMapClient.delete("deleteStudent", id);

} catch (SQLException e) {

e.printStackTrace();

}

 

}

3. 调试结果

public static void main(String[] args) {

IStudentDAO dao = new IStudentDAOImpl();

 

for(Student stu : dao.queryAllStudent()) {

System.out.println(stu);

}

//删除sid7的数据

dao.deleteStudentById(7);

System.out.println("#############");

for(Student stu : dao.queryAllStudent()) {

System.out.println(stu);

}

}

[sid:7, name:fengge, major:null, birth:Tue Oct 05 00:00:00 CST 2010, score:110.0]

[sid:1, name:李明, major:语文, birth:Tue Mar 27 00:00:00 CST 2018, score:100.0]

[sid:2, name:可可, major:英语, birth:Mon Mar 12 00:00:00 CST 2018, score:120.0]

[sid:3, name:天天, major:数学, birth:Thu Mar 22 00:00:00 CST 2018, score:80.0]

#############

[sid:1, name:李明, major:语文, birth:Tue Mar 27 00:00:00 CST 2018, score:100.0]

[sid:2, name:可可, major:英语, birth:Mon Mar 12 00:00:00 CST 2018, score:120.0]

[sid:3, name:天天, major:数学, birth:Thu Mar 22 00:00:00 CST 2018, score:80.0]

相关文章:

  • 2021-08-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-04
  • 2022-12-23
猜你喜欢
  • 2021-07-18
  • 2021-12-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-01
  • 2021-11-22
相关资源
相似解决方案