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

soho做网站多少钱重庆长寿网站设计公司哪家好

soho做网站多少钱,重庆长寿网站设计公司哪家好,o2o电子商务网站开发与运营,wordpress 自动发货插件题目要求: 使用动态SQL进行条件查询、更新以及复杂查询操作。本实验要求利用本章所学知识完成一个学生信息系统#xff0c;该系统要求实现3个以下功能: 1、多条件查询#xff1a; 当用户输入的学生姓名不为空#xff0c;则根据学生姓名进行学生信息的查询#xff1b; 当用户…题目要求: 使用动态SQL进行条件查询、更新以及复杂查询操作。本实验要求利用本章所学知识完成一个学生信息系统该系统要求实现3个以下功能: 1、多条件查询 当用户输入的学生姓名不为空则根据学生姓名进行学生信息的查询 当用户输入的学生姓名为空而学生专业不为空则只根据学生专业进行学生的查询当学生姓名和专业都为空则查询所有学生信息 2、单条件查询查询出所有id值小于5的学生的信息 实验步骤: 先创建一个数据库 user 表 CREATE TABLE user(id int(32) PRIMARY KEY AUTO_INCREMENT,name varchar(50),major varchar(50),userId varchar(16) ); 再插入数据 # 插入7条数据 INSERT INTO user VALUES (1, 张三, spring, 202101); INSERT INTO user VALUES (2, 李四, mybatis, 202102); INSERT INTO user VALUES (3, 王二, reids, 202103); INSERT INTO user VALUES (4, 小张, springMVC, 202104); INSERT INTO user VALUES (5, 小红, springBoot, 202105); INSERT INTO user VALUES (6, 小王, springcloud, 202106); INSERT INTO user VALUES (7, 小芬, vue, 202107); 1.创建maven项目在pom.xml文件中配置以依赖 2.创建实体类StudentEntity 3.创建jdbc.properties和mybatis-config.xml配置文件 4.创建StudentMapper接口 5.在mybatis-config.xml文件中注册StudentMapper.xml 6.创建测试类 7.工具类 8.测试结果 项目结构: 1.创建maven项目在pom.xml文件中配置以依赖 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdorg.example/groupIdartifactIdExample/artifactIdversion1.0-SNAPSHOT/versionpropertiesmaven.compiler.source17/maven.compiler.sourcemaven.compiler.target17/maven.compiler.target/propertiesdependenciesdependencygroupIdorg.mybatis/groupIdartifactIdmybatis/artifactIdversion3.5.2/version/dependencydependencygroupIdjunit/groupIdartifactIdjunit/artifactIdversion4.12/versionscopetest/scope/dependencydependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactIdversion8.0.11/version/dependency/dependenciesbuildresourcesresourcedirectorysrc/main/java/directoryincludesinclude**/*.properties/includeinclude**/*.xml/include/includesfilteringtrue/filtering/resource/resources/build /project 2.创建实体类StudentEntity package com.gcy.entity;public class StudentEntity {private Integer id;private String name;private String major;private String sno;public Integer getId() {return id;}public void setId(Integer id) {this.id id;}public String getName() {return name;}public void setName(String name) {this.name name;}public String getMajor() {return major;}public void setMajor(String major) {this.major major;}public String getSno() {return sno;}public void setSno(String sno) {this.sno sno;}Overridepublic String toString() {return StudentEntity{ id id , name name \ , major major \ , sno sno \ };} }3.创建jdbc.properties和mybatis-config.xml配置文件 jdbc.properties jdbc.drivercom.mysql.jdbc.Driver jdbc.urljdbc:mysql://127.0.0.1:3306/mybatis?serverTimezoneUTCcharacterEncodingutf8useUnicodetrueuseSSLfalse jdbc.usernameroot jdbc.password200381 mybatis-config.xml ?xml version1.0 encodingUTF-8 ? !DOCTYPE configurationPUBLIC -//mybatis.org//DTD Config 3.0//ENhttp://mybatis.org/dtd/mybatis-3-config.dtd configuration!-- 环境配置 --!-- 加载类路径下的属性文件 --properties resourcejdbc.properties/environments defaultdevelopmentenvironment iddevelopmenttransactionManager typeJDBC/!-- 数据库连接相关配置 ,db.properties文件中的内容--dataSource typePOOLEDproperty namedriver value${jdbc.driver}/property nameurl value${jdbc.url}/property nameusername value${jdbc.username}/property namepassword value${jdbc.password}//dataSource/environment/environmentsmappersmapper resourcecom/gcy/mapper/StudentMaper.xml//mappers /configuration 4.创建StudentMapper接口 package com.gcy.mapper; import com.gcy.entity.StudentEntity; import java.util.List; public interface StudentMapper {ListStudentEntity findStudentByName(StudentEntity student);ListStudentEntity findStudentById(Integer[] array);ListStudentEntity findAllStudent(StudentEntity student);ListStudentEntity findStudentByNameOrMajor(StudentEntity student); } 5.在mybatis-config.xml文件中注册StudentMapper.xml ?xml version1.0 encodingUTF8? !DOCTYPE mapperPUBLIC -//mybatis.org//DTD mapper 3.0//ENhttp://mybatis.org/dtd/mybatis-3-mapper.dtd mapper namespacecom.gcy.mapper.StudentMapperselect idfindStudentByName parameterTypecom.gcy.entity.StudentEntityresultTypecom.gcy.entity.StudentEntityselect * from user where 11if testname!null and name!and name like concat(%,#{name},%)/if/selectselect idfindStudentByNameOrMajor parameterTypecom.gcy.entity.StudentEntityresultTypecom.gcy.entity.StudentEntityselect * from userwherechoosewhen testname !null and name !and name like concat(%,#{name}, %)/whenwhen testmajor !null and major !and major #{major}/when/choose/where/selectselect idfindAllStudent parameterTypecom.gcy.entity.StudentEntityresultTypecom.gcy.entity.StudentEntityselect * from userwherechoosewhen testname !null and name !and name like concat(%,#{name}, %)/whenwhen testmajor !null and major !and major #{major}/whenotherwiseand id is not null/otherwise/choose/where/selectselect idfindStudentById parameterTypejava.util.ArraysresultTypecom.gcy.entity.StudentEntityselect * from userwhereforeach itemid indexindex collectionarrayopenid in( separator, close)#{id}/foreach/where/select /mapper 6.工具类 package com.gcy.utils; import java.io.Reader; import org.apache.ibatis.io.Resources; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactoryBuilder; /*** 工具类*/ public class MyBatisUtils {private static SqlSessionFactory sqlSessionFactory;// 初始化SqlSessionFactory对象static {try {// 使用MyBatis提供的Resources类加载MyBatis的配置文件Reader reader Resources.getResourceAsReader(mybatis-config.xml);// 构建SqlSessionFactory工厂sqlSessionFactory new SqlSessionFactoryBuilder().build(reader);} catch (Exception e) {e.printStackTrace();}}// 获取SqlSession对象的静态方法public static SqlSession getSession() {return sqlSessionFactory.openSession();} } 7.创建测试类 import com.gcy.entity.StudentEntity; import com.gcy.mapper.StudentMapper; import com.gcy.utils.MyBatisUtils; import org.apache.ibatis.session.SqlSession;import java.util.List;public class Test {org.junit.Testpublic void Test01(){SqlSession session MyBatisUtils.getSession();StudentMapper mapper session.getMapper(StudentMapper.class);StudentEntity student new StudentEntity();student.setName(张三);ListStudentEntity findStudentByName mapper.findStudentByName(student);System.out.println(************************* 姓名不为空 *******************);for (StudentEntity s : findStudentByName) {System.out.println(s);}session.close();}org.junit.Testpublic void Test02(){SqlSession session MyBatisUtils.getSession();StudentMapper mapper session.getMapper(StudentMapper.class);StudentEntity student new StudentEntity();student.setMajor(spring);ListStudentEntity studentByNameOrMajor mapper.findStudentByNameOrMajor(student);System.out.println(************************* 专业不为空 *******************);for (StudentEntity s : studentByNameOrMajor) {System.out.println(s);}session.close();}org.junit.Testpublic void Test03(){SqlSession session MyBatisUtils.getSession();StudentMapper mapper session.getMapper(StudentMapper.class);StudentEntity student new StudentEntity();ListStudentEntity allStudent mapper.findAllStudent(student);System.out.println(************************* 学号不为空 *******************);for (StudentEntity s : allStudent) {System.out.println(s);}session.close();}org.junit.Testpublic void Test04(){SqlSession session MyBatisUtils.getSession();StudentMapper mapper session.getMapper(StudentMapper.class);Integer[] strId {1,2,3,4};ListStudentEntity studentById mapper.findStudentById(strId);System.out.println(************************* 前面4位 *******************);for (StudentEntity s : studentById) {System.out.println(s);}} }8.测试结果
http://www.dnsts.com.cn/news/150996.html

相关文章:

  • 网站建设微商城电子商务网站系统的开发设计
  • 做图书出版 外国网站上海市建筑网
  • 宁波品牌网站建设建网站怎么赚钱
  • 重庆手机网站建设哈尔滨百姓网
  • 只做财经的网站找网页设计公司去哪个平台
  • 一般网站图标是用什么做的做网站策划书吧
  • 润滑油 东莞网站建设网站建设哪些是需要外援的问题
  • 网站上二维码怎么做的v2ex wordpress
  • 张家港电脑网站制作建设培训网站办安全员c证
  • 招远做网站联系电话高端网站首页
  • 北京网站快速优化排名wordpress最新文章链接插件
  • 商河做网站公司网站需备案
  • 安徽天长建设局网站襄垣网站建设
  • 网站制作代理淘宝便宜的团购网站建设
  • 网站备案修改域名凡科做网站好吗
  • 广告网站设计怎么样企业网站搜索推广
  • asp网站攻击雄安新区网站建设
  • 做商城网站的企业网站转移权重
  • 做文献ppt模板下载网站有哪些福建自适应网站建设
  • 服装网站的设计理念广东手机网页制作
  • 网站在线订单系统怎么做折扣卡网站建设
  • 删除西部数码网站管理助手网站空间怎么申请
  • 昆明做网站建设哪家好玛沁县网站建设公司
  • 高校移动门户网站建设wordpress有声主题
  • 深圳推广公司网站建设书模板湛江网站建设运营方案
  • 网站上文章加入音乐是怎么做的最新引流推广方法
  • 什么网站需要数据库做搜索引擎优化对网站有哪些好处
  • 青岛专业网站制作怎么做免费的公司网站
  • 福州网站排名优化七牛 wordpress 插件
  • 高端网站建设 杭州汕尾做网站