1. 映射文件配置如下信息

 <select id="selectStudentById" resultClass="Student" parameterClass="int">

   select sid, name, major, birth, score from student where sid=#sid#

  </select>

2. 实现类方法实现

public Student queryStudentById(int id) {

Student student = null;

try {

student = (Student) sqlMapClient.queryForObject("selectStudentById", id);

} catch (SQLException e) {

e.printStackTrace();

}

return student;

}

3. 测试及其结果

public static void main(String[] args) {

IStudentDAO dao = new IStudentDAOImpl();

/* for(Student student : dao.queryAllStudent()) {

System.out.println(student);

}

*/

 System.out.println(dao.queryStudentById(1));

}

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

 

相关文章:

  • 2021-10-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-25
  • 2022-12-23
猜你喜欢
  • 2021-08-21
  • 2021-10-24
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
相关资源
相似解决方案