1、利用BeanUtils的前提得要加入以下两个jar包:

commons-beanutils-1.8.0.jar

commons-logging-1.1.1.jar

package com.shellway.jdbcDAO;

import java.util.List;
import org.junit.Test;

public class TestDAO {
    DAO dao = new DAO();

    @Test
    public void testUpdate() throws Exception {
        String sql = "update examstudent set grade=? where flow_id=12345";
        dao.update(sql, 88);
    }

    @Test
    public void test() throws Exception {

        String sql = "select flow_id flowID,type,id_card idCard, "
                + "exam_card examCard,student_name studentName,location,grade "
                + "from examstudent where flow_id = ? ";
        Student stu = dao.get(Student.class, sql, 12345);
        System.out.println(stu);
    }

    @Test
    public void testGetSome() throws Exception {
        String sql = "select flow_id flowID,type,id_card idCard, "
                + "exam_card examCard,student_name studentName,location,grade "
                + "from examstudent";
        List<Student> students = dao.getForList(Student.class, sql);
        System.out.println(students);
    }

    @Test
    public void testGetForValue() throws Exception {
        String sql = "select grade from examstudent where flow_id = ? ";
        Object obj = dao.getforvalue(sql, 123456);
        System.out.println(obj);
    }
}
测试类

相关文章:

  • 2022-12-23
  • 2021-09-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-08
  • 2022-12-23
猜你喜欢
  • 2021-11-19
  • 2022-01-16
  • 2022-12-23
  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案