今天mybatis结尾 明天学html
/* @Test public void testadd() throws IOException { //接收参数 int status=1; String companyName ="大太阳"; String brandName = "big sun pro"; String description="i m god"; int ordered =100; //对象参数 则封装对象 Brand brand=new Brand(); brand.setStatus(status); brand.setCompanyName(companyName); brand.setBrandName(brandName); brand.setDescription(description); brand.setOrdered(ordered); //brand.setCompanyName(companyName); //brand.setBrandName(brandName); *//* Map map=new HashMap(); // map.put("status",status); map.put("companyName",companyName); map.put("brandName",brandName); *//* //1.获取sqlsessionfactory,直接复制粘贴 String resource = "mybatis-config.xml"; InputStream inputStream = Resources.getResourceAsStream(resource); SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream); //2.获取sqlsession对象 SqlSession sqlSession = sqlSessionFactory.openSession(true); //3.获取mapper接口的代理对象 Brandmapper brandmapper = sqlSession.getMapper(Brandmapper.class); //4.执行方法 brandmapper.add(brand); System.out.println(brand.getId()); *//* //提交事务 sqlSession.commit();;*//* sqlSession.close(); }*/ /* @Test public void testdelete() throws IOException { //接收参数 */ /* int status=1; String companyName ="大太阳"; String brandName = "big sun pro"; String description="i m god,supergod"; int ordered =200;*//* int id=7; //对象参数 则封装对象 Brand brand=new Brand(); */ /* brand.setStatus(status); brand.setCompanyName(companyName); brand.setBrandName(brandName); brand.setDescription(description); brand.setOrdered(ordered);*//* brand.setId(id); //brand.setCompanyName(companyName); //brand.setBrandName(brandName); */ /* Map map=new HashMap(); // map.put("status",status); map.put("companyName",companyName); map.put("brandName",brandName); *//* //1.获取sqlsessionfactory,直接复制粘贴 String resource = "mybatis-config.xml"; InputStream inputStream = Resources.getResourceAsStream(resource); SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream); //2.获取sqlsession对象 SqlSession sqlSession = sqlSessionFactory.openSession(true); //3.获取mapper接口的代理对象 Brandmapper brandmapper = sqlSession.getMapper(Brandmapper.class); //4.执行方法 brandmapper.delete(brand); */ /* //提交事务 sqlSession.commit();;*//* sqlSession.close(); } */ @Test public void testdeletebyids() throws IOException { //接收参数 /* int status=1; String companyName ="大太阳"; String brandName = "big sun pro"; String description="i m god,supergod"; int ordered =200;*/ int[] ids={1,2,3}; //对象参数 则封装对象 /* Brand brand=new Brand();*/ /* brand.setStatus(status); brand.setCompanyName(companyName); brand.setBrandName(brandName); brand.setDescription(description); brand.setOrdered(ordered);*/ /*brand.setId(id);*/ //brand.setCompanyName(companyName); //brand.setBrandName(brandName); /* Map map=new HashMap(); // map.put("status",status); map.put("companyName",companyName); map.put("brandName",brandName); */ //1.获取sqlsessionfactory,直接复制粘贴 String resource = "mybatis-config.xml"; InputStream inputStream = Resources.getResourceAsStream(resource); SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream); //2.获取sqlsession对象 SqlSession sqlSession = sqlSessionFactory.openSession(true); //3.获取mapper接口的代理对象 Brandmapper brandmapper = sqlSession.getMapper(Brandmapper.class); //4.执行方法 brandmapper.deletebyids(ids); /* //提交事务 sqlSession.commit();;*/ sqlSession.close(); } }
标签:mabatis,周四,结尾,companyName,brand,sqlSession,map,brandName,String From: https://www.cnblogs.com/zeyangshuaige/p/17585752.html