美文网首页
TestJdbcUtil

TestJdbcUtil

作者: jinhm007 | 来源:发表于2019-01-21 00:04 被阅读0次

    package com.test.demo.jdbc;

    import org.junit.Test;

    import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;

    import java.util.HashMap;

    import java.util.List;

    import java.util.Map;

    import static com.test.demo.utils.CompareUtil.compareMap;

    import static org.junit.Assert.assertEquals;

    /**

    * @ClassName: TestJdbcUtil

    * @Description: JdbcUtil的测试用例 ,硬编码方式。*

    */

    public class TestJdbcUtil {

    private NamedParameterJdbcTemplatemysqlJdbc01=DBEnum.Mysql.getNamedParameterJdbcTemplate("jdbc:mysql://localhost:3306/my_db?useUnicode=true&characterEncoding=utf-8","root", "666666");

      private NamedParameterJdbcTemplatemysqlJdbc=DBEnum.Mysql.getNamedParameterJdbcTemplate("jdbc:mysql://localhost:3306/mock?useUnicode=true&characterEncoding=utf-8","root", "666666");

      Mapargs =new HashMap();

      Mapargs2 =new HashMap();

      @Test

      public void testMysqlJdbcTemplate() {

    args.put("sex", "1");

          List> result=JdbcUtil.queryData(mysqlJdbc, "getUserListCase", args);

          System.out.println(result);

      }

    /**

      * <p>Title: JdbcUtil

      * <p>Description:采用greentest中的JdbcUtil方法

      */

      @Test

      public void testOracleJdbcTemplate() {

    args.put("sex", "1");

          List> result=JdbcUtil.queryData(mysqlJdbc01, "getUserListCase", args);

          System.out.println(result);

      }

    @Test

      public void test() {

    args.put("sex", "1");

          List> result1=JdbcUtil.queryData(mysqlJdbc01, "getUserListCase", args);

          System.out.println(result1);

          args2.put("sex", "1");

          List> result2=JdbcUtil.queryData(mysqlJdbc, "getUserListCase", args);

          System.out.println(result2);

          compareMap(result1,result2);

      }

    /**

      * <p>Title: NamedParameterJdbcTemplate

      * <p>Description:采用 NamedParameterJdbcTemplate的方法执行sql

      * */

    /* @Test

    public void testNamedParameterJdbcTemplate() {

    String sql ="select * from expert where expertuuid=:expertuuid";

    args.put("expertuuid", "125618762378427");

    List> result=oracleJdbc.queryForList(sql,args);

    System.out.println(result);

    assertEquals("傅雯雯",result.get(0).get("EXPERTNAME"));

    }*/

    }

    相关文章

      网友评论

          本文标题:TestJdbcUtil

          本文链接:https://www.haomeiwen.com/subject/odcqjqtx.html