当前位置: 首页 > news >正文

哪个网站做视频钱多模仿做网站

哪个网站做视频钱多,模仿做网站,网页是啥,做网站电话销售2023.10.29 本章学习MyBatis的基本crud操作。 insert java程序如下#xff1a; ①使用map集合传参 Testpublic void testInsertCar(){SqlSession sqlSession SqlSessionUtil.openSession();//先将数据放到Map集合中#xff0c;在sql语句中使用 #{map集合的key} 来完成传…2023.10.29 本章学习MyBatis的基本crud操作。 insert java程序如下 ①使用map集合传参 Testpublic void testInsertCar(){SqlSession sqlSession SqlSessionUtil.openSession();//先将数据放到Map集合中在sql语句中使用 #{map集合的key} 来完成传值#{} 等同于JDBC中的 ? #{}就是占位符MapString,Object map new HashMap();map.put(carNum, 1029);map.put(brand, 马自达);map.put(guidePrice, 50.3);map.put(produceTime, 2023-10-29);map.put(carType, 燃油车);// 执行SQL语句使用map集合给sql语句传递数据int count sqlSession.insert(insertCar, map);System.out.println(插入了几条记录 count);sqlSession.commit();sqlSession.close();} ②使用pojo传参 Testpublic void testInsertCarByPOJO(){SqlSession sqlSession SqlSessionUtil.openSession();Car car new Car(null,1029,马自达,50.3,2023-10-29,燃油车);int count sqlSession.insert(insertCar,car);System.out.println(count);sqlSession.commit();sqlSession.close();} SQL语句如下 insert idinsertCarinsert into t_car(id,car_num,brand,guide_price,produce_time,car_type) values (null,#{carNum},#{brand},#{guidePrice},#{produceTime},#{carType}); /insert 运行结果 ps如果采用map集合传参#{} 里写的是map集合的key如果key不存在不会报错数据库表中会插入NULL。 ps如果采用POJO传参#{} 里写的是POJO类中get方法的方法名去掉get之后将剩下的单词首字母变小写例如getAge对应的是#{age}getUserName对应的是#{userName}如果这样的get方法不存在会报错。 delete 需求根据car_num进行删除。 java程序如下 Testpublic void testDeleteById(){SqlSession sqlSession SqlSessionUtil.openSession();int count sqlSession.delete(deleteById,2);sqlSession.commit();sqlSession.close();} sql语句如下 delete iddeleteByIddelete from t_car where id #{id}/delete 运行结果 ps当占位符只有一个的时候${} 里面的内容可以随便写。 update java代码如下 Testpublic void testUpdateById(){SqlSession sqlSession SqlSessionUtil.openSession();Car car new Car(21L,1029,宝马7系,66.6,1999-11-23,燃油车);int count sqlSession.update(updateById,car);System.out.println(count);sqlSession.commit();sqlSession.close();} sql语句如下 update idupdateByIdupdate t_car setcar_num #{carNum}, brand #{brand},guide_price #{guidePrice}, produce_time #{produceTime},car_type #{carType}where id #{id}/update 运行结果 select  查询一条数据 需求查询id为21的Car信息 java代码如下 Testpublic void testSelectCarById(){// 获取SqlSession对象SqlSession sqlSession SqlSessionUtil.openSession();// 执行SQL语句Object car sqlSession.selectOne(selectCarById, 21);System.out.println(car);} sql语句如下 select idselectCarById resultTypepojo.Carselectid, car_num as carNum, brand, guide_price as guidePrice, produce_time as produceTime, car_type as carTypefromt_carwhereid #{id}/select 运行结果 ps当查询结果的字段名和java类的属性名对应不上的话可以采用as关键字起别名 。 查询多条数据 java代码如下 Testpublic void testSelectCarAll(){// 获取SqlSession对象SqlSession sqlSession SqlSessionUtil.openSession();// 执行SQL语句ListObject cars sqlSession.selectList(selectCarAll);// 输出结果cars.forEach(car - System.out.println(car));} sql语句如下 !--虽然结果是List集合但是resultType属性需要指定的是List集合中元素的类型。--select idselectCarAll resultTypepojo.Car!--记得使用as起别名让查询结果的字段名和java类的属性名对应上。--selectid, car_num as carNum, brand, guide_price as guidePrice, produce_time as produceTime, car_type as carTypefromt_car/select 由于我数据库只有一条记录先手动添加几条记录 运行查询语句结果为 ps在SQL Mapper配置文件中mapper标签的namespace属性可以翻译为命名空间这个命名空间主要是为了防止sqlId冲突的。
http://wiki.neutronadmin.com/news/99017/

相关文章:

  • 谢岗仿做网站网站建设平台简介
  • 网站做资讯需要获取许可证吗成都网站seo技巧
  • 东莞沙田网站建设迅速建设企业网站
  • 网站建设与网页设计作业专业网站设计公司价格
  • 重庆网站排名优化公司wordpress支持内网和外网
  • 大连网站设计哪里有做旧版优化大师
  • 网页设计制作网站首页抖音企业推广费用
  • 防城港做网站安卓优化大师旧版
  • 全国做旅游开发的公司搜索引擎排名优化建议
  • 广东建设中标网站重庆注册公司网上申请入口
  • 沈阳网站优化 唐朝网络程序员外包公司有哪些
  • 仿制别人的网站违法吗咋制作网站
  • 秦皇岛中兵建设集团网站海报设计素材网站免费
  • 计算机网站开发书籍网页设计属于平面设计吗
  • 非经营备案网站能贴放广告么深圳网站建设设计首选公司
  • 北京网站策划公司seo工具网站
  • 咸阳免费做网站网站后台如何添加附件
  • 房地产项目网站建设拓展公司网站建设
  • 做微信首图的网站龙华网站制作要多少钱
  • 捷信做单网站家用电脑桌面做网站
  • 长春模板网站建设企业安装wordpress时出现空白
  • 专业建设网站公司排名网站自己怎么建设
  • 网站外包价格怎么注册自己的app
  • 卖做游戏点卡网站创业宁波建网站找哪家
  • 南山区住房和建设局网站设计经典网站
  • 网站关闭公告代码wordpress 数字不连续
  • 惠州市 网站开发公司免费做网站优化
  • 莆田网站开发公司上海婚恋网站排名
  • 网页设计代码网站做美图 网站
  • 网站建设相对应的税收分类是个人网站程序下载