
mybatis
~甲壳虫
这个作者很懒,什么都没留下…
展开
-
mybatis之使用德鲁伊连接池及配置
在pom.xml文件中安装依赖<dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.10</version></dependency>在mybatis-config.xml配置文件中改变数据连接<environments default="mysql">原创 2021-09-21 16:16:41 · 1978 阅读 · 0 评论 -
mybatis加载配置文件,及封装工具类
@Testpublic void querySubjectById() { try { /*向数据库添加数据*/ //1.加载配置文件 InputStream inputStream = Resources.getResourceAsStream("mybatis-config.xml"); //2.获取sqlSessionFactory工厂 SqlSessionFactory sqlSessionFactory =原创 2021-09-21 16:12:32 · 113 阅读 · 0 评论 -
mybatis各种小知识点二:嵌套查询之一对一,多对多
CREATE TABLE t_passengers (id int NOT NULL AUTO_INCREMENT,name varchar(50) DEFAULT NULL,sex varchar(1) DEFAULT NULL,birthday date DEFAULT NULL,PRIMARY KEY (id)) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;CREATE TABLE t_passports (id int NO原创 2021-09-21 16:08:32 · 165 阅读 · 0 评论 -
mybatis各种小知识点二:嵌套查询之一对多,多对一
使用的表CREATE TABLE t_departments (id int NOT NULL AUTO_INCREMENT,name varchar(50) DEFAULT NULL,location varchar(100) DEFAULT NULL,PRIMARY KEY (id)) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;CREATE TABLE t_employees (id int NOT NULL AUTO_INC原创 2021-09-21 15:52:20 · 132 阅读 · 0 评论 -
mybatis各种小知识点一
抽取sql片段<!--抽取重复的sql片段--> <sql id="user_field"> select id,username,password,gender,regist_time from t_user </sql> <!--根据id查询--> <select id="queryUserById" resultType="User"> <include原创 2021-09-21 15:20:53 · 70 阅读 · 0 评论 -
mybatis-config.xml核心配置文件&log4j配置文件
mybatis-config.xml核心配置文件<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"><configuration> <!--导入外部的配置文件-->原创 2021-09-21 14:03:13 · 210 阅读 · 0 评论