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

网站找不到首页邢台168交友

网站找不到首页,邢台168交友,泉州网站建设公司推荐,天猫店项目实现的功能 查询所有用户信息 通过Id查询用户信息 添加用户#xff08;回显主键#xff09; 修改用户信息 删除用户信息 通过用户名字模糊查询 一、引入依赖和工程结构 ?xml version1.0 encodingUTF-8? project xmlnshttp…项目实现的功能 查询所有用户信息 通过Id查询用户信息 添加用户回显主键 修改用户信息 删除用户信息 通过用户名字模糊查询 一、引入依赖和工程结构 ?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/modelVersiongroupIdcom.william/groupIdartifactIdMybatisCRUD/artifactIdversion1.0-SNAPSHOT/versionpropertiesmaven.compiler.source1.8/maven.compiler.sourcemaven.compiler.target1.8/maven.compiler.target/propertiesdependenciesdependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactIdversion5.1.47/version/dependencydependencygroupIdorg.mybatis/groupIdartifactIdmybatis/artifactIdversion3.4.5/version/dependencydependencygroupIdjunit/groupIdartifactIdjunit/artifactIdversion4.12/version/dependencydependencygroupIdlog4j/groupIdartifactIdlog4j/artifactIdversion1.2.17/version/dependency/dependencies/project二、创建实体类 User package com.william.domain;import java.util.Date;/*** author lijunxuan* date Created in 2019/7/9 19:28* description * version: 1.0*/ public class User {private Integer id;private String username;private String password;private String sex;private Date birthday;Overridepublic String toString() {return User{ id id , username username \ , password password \ , sex sex \ , birthday birthday };}public Date getBirthday() {return birthday;}public void setBirthday(Date birthday) {this.birthday birthday;}public Integer getId() {return id;}public void setId(Integer id) {this.id id;}public String getUsername() {return username;}public void setUsername(String username) {this.username username;}public String getPassword() {return password;}public void setPassword(String password) {this.password password;}public String getSex() {return sex;}public void setSex(String sex) {this.sex sex;}} 三、映射文件 1.UserMapper.xml ?xml version1.0 encodingUTF-8 ? !DOCTYPE mapperPUBLIC -//mybatis.org//DTD Mapper 3.0//ENhttp://mybatis.org/dtd/mybatis-3-mapper.dtd mapper namespacecom.william.mapper.UserMapper!--查询所有用户信息--select idfindAll resultTypecom.william.domain.Userselect * from user/select!--通过ID查询用户信息--select idfindById parameterTypejava.lang.Integer resultTypecom.william.domain.Userselect * from user where id#{id}/select!--模糊查询--select idfindByUsername parameterTypejava.lang.String resultTypecom.william.domain.Userselect * from user where username like %#{value}%/select!--增加用户信息--insert idinsert parameterTypecom.william.domain.User-- 主键回显selectKey resultTypejava.lang.Integer keyColumnid keyPropertyid orderAFTER select last_insert_id()/selectKeyinsert into user values (null ,#{username},#{password},#{sex},#{birthday})/insert!--更新用户信息--update idupdate parameterTypecom.william.domain.Userupdate user set username#{username},password#{password},sex#{sex},birthday#{birthday} where id#{id}/update!--删除用户信息--delete iddelete parameterTypejava.lang.Integerdelete from user where id #{id}/delete /mapper2.Mybatis-configuration.xml ?xml version1.0 encodingUTF-8 ? !DOCTYPE configurationPUBLIC -//mybatis.org//DTD Config 3.0//ENhttp://mybatis.org/dtd/mybatis-3-config.dtd configurationenvironments defaultdevelopmentenvironment iddevelopmenttransactionManager typeJDBC/dataSource typePOOLEDproperty namedriver valuecom.mysql.jdbc.Driver/property nameurl valuejdbc:mysql://localhost:3306/web02/property nameusername valueroot/property namepassword valueroot//dataSource/environment/environmentsmappersmapper resourcecom/william/mapper/UserMapper.xml//mappers /configuration四、引入log4j log4j.properties # Set root category priority to INFO and its only appender to CONSOLE. #log4j.rootCategoryINFO, CONSOLE debug info warn error fatal log4j.rootCategorydebug, CONSOLE, LOGFILE, info# Set the enterprise logger category to FATAL and its only appender to CONSOLE. log4j.logger.org.apache.axis.enterpriseFATAL, CONSOLE# CONSOLE is set to be a ConsoleAppender using a PatternLayout. log4j.appender.CONSOLEorg.apache.log4j.ConsoleAppender log4j.appender.CONSOLE.layoutorg.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.ConversionPattern%d{ISO8601} %-6r [%15.15t] %-5p %30.30c %x - %m\n# LOGFILE is set to be a File appender using a PatternLayout. log4j.appender.LOGFILEorg.apache.log4j.FileAppender log4j.appender.LOGFILE.Filed:\axis.log log4j.appender.LOGFILE.Appendtrue log4j.appender.LOGFILE.layoutorg.apache.log4j.PatternLayout log4j.appender.LOGFILE.layout.ConversionPattern%d{ISO8601} %-6r [%15.15t] %-5p %30.30c %x - %m\n 五、测试类 TestMybatis package com.william; import com.william.domain.User; import org.apache.ibatis.io.Resources; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactoryBuilder; import org.junit.Test; import java.io.InputStream; import java.util.Date; import java.util.List; /*** author lijunxuan* date Created in 2019/7/9 19:45* description * version: 1.0*/ public class TestMybatis {/*** 查询所有用户信息*/Testpublic void selectList(){InputStream inputStream Resources.class.getClassLoader().getResourceAsStream(Mybatis-configuration.xml);SqlSessionFactory sqlSessionFactory new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession sqlSessionFactory.openSession();ListUser selectList sqlSession.selectList(com.william.mapper.UserMapper.findAll);for (Object o : selectList) {System.out.println(o);}sqlSession.close();}/***通过Id查询用户信息**/Testpublic void findById(){InputStream inputStream Resources.class.getClassLoader().getResourceAsStream(Mybatis-configuration.xml);SqlSessionFactory sqlSessionFactory new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession sqlSessionFactory.openSession();User selectOne sqlSession.selectOne(com.william.mapper.UserMapper.findById, 43);System.out.println(selectOne.getUsername());sqlSession.close();}/*** 添加用户*/Testpublic void InsertUser(){InputStream inputStream Resources.class.getClassLoader().getResourceAsStream(Mybatis-configuration.xml);SqlSessionFactory sqlSessionFactory new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession sqlSessionFactory.openSession();User user new User();user.setUsername(黑衣人);user.setPassword(123456);user.setSex(男);user.setBirthday(new Date());sqlSession.insert(com.william.mapper.UserMapper.insert,user);//回显刚刚添加用户的IDSystem.out.println(添加之后的主键id为user.getId());sqlSession.commit();sqlSession.close();}/*** 修改用户信息*/Testpublic void UpdateUser(){InputStream inputStream Resources.class.getClassLoader().getResourceAsStream(Mybatis-configuration.xml);SqlSessionFactory sqlSessionFactory new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession sqlSessionFactory.openSession();User user new User();user.setId(43);user.setUsername(黑衣人);user.setPassword(123456);user.setSex(男);user.setBirthday(new Date());sqlSession.update(com.william.mapper.UserMapper.update,user);sqlSession.commit();sqlSession.close();}/*** 删除用户信息*/Testpublic void deleteUser(){InputStream inputStream Resources.class.getClassLoader().getResourceAsStream(Mybatis-configuration.xml);SqlSessionFactory sqlSessionFactory new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession sqlSessionFactory.openSession();sqlSession.delete(com.william.mapper.UserMapper.delete,42);sqlSession.commit();sqlSession.close();}/*** 模糊查询* 通过用户名字模糊查询*/Testpublic void findByUsername(){InputStream inputStream Resources.class.getClassLoader().getResourceAsStream(Mybatis-configuration.xml);SqlSessionFactory sqlSessionFactory new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession sqlSessionFactory.openSession();ListUser selectList sqlSession.selectList(com.william.mapper.UserMapper.findByUsername,a);for (Object o : selectList) {System.out.println(o);}sqlSession.close();} }
http://www.pierceye.com/news/6287/

相关文章:

  • thinphp 做外贸网站惠州企业自助建站
  • 文教设施网站制作方案网络广告学心得体会
  • 青岛网站设计软件衙门口网站建设
  • 网站设计师薪资oa系统办公软件怎么用
  • 要做一个网站得怎么做辽宁沈阳又发现一例吗今天
  • 南昌做网站建站的网站的优化推广方案
  • 猎聘网网站建设目标建设企业银行怎么转账
  • 网站宽度多少合适wordpress自定义缩略图
  • 西安借贷购物网站建设律师在哪个网站做推广比较好
  • 做网站需要用什么开发软件网站空间有免费的吗
  • 网站设计论文前言公众号怎么发文章
  • 百度收录较好的网站学校官网页面设计
  • 建设网站的网站discuz网站ip
  • 便捷网站建设多少钱做一万个网站
  • 泸州网站seo永久无限免费看的app
  • 网站域名实名认证站长工具站长
  • 自己的网站怎么优化国际网站设计
  • 建网站北京网站设置仅某浏览器
  • 青浦网站开发拍卖网站建设方案
  • 做房地产公司网站的费用四川省红鱼洞水库建设管理网站
  • 网站设计济南怎样做淘宝网站建设
  • 机关网站机制建设情况做外贸的收入一般多少
  • 网站开发设计运维重庆网站推广专家
  • 做别墅花园绿化的网站wordpress仿谷歌主题
  • 珠海哪里有网站建设华为官方手表网站
  • 知名网站制作公司有哪些平面电商网站建设
  • 电子商城网站开发购物车济南广运建设公司网站
  • 如何购买网站流量有哪些网站做的比较好的
  • 国外平面设计素材网站房地产行业网站开发
  • 南宁市规划建设局 网站德州网站有哪些