首先我们需要先下载jar包

其次我们书写具体的内容

Student  Class

package entity;
/*
* 学生类
* */
public class Student {
//学生编号
private Integer sid;
//学生名称
private String sname;
//学生性别
private String sex; public Student() {
}
public Student(String sname, String sex) {
this.sname = sname;
this.sex = sex;
}
public Integer getSid() {
return sid;
}
public void setSid(Integer sid) {
this.sid = sid;
}
public String getSname() {
return sname;
}
public void setSname(String sname) {
this.sname = sname;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
} }

  Grade  Class

package entity;
/*
* 班级类
* */
public class Grade {
//班级编号
private Integer gid;
//班级名称
private String gname;
//班级描述
private String gdesc; public Grade() {
}
public Grade(Integer gid, String gname, String gdesc) {
this.gid = gid;
this.gname = gname;
this.gdesc = gdesc;
}
public Integer getGid() {
return gid;
}
public void setGid(Integer gid) {
this.gid = gid;
}
public String getGname() {
return gname;
}
public void setGname(String gname) {
this.gname = gname;
}
public String getGdesc() {
return gdesc;
}
public void setGdesc(String gdesc) {
this.gdesc = gdesc;
} }

  

接下来我们就要配置只要文件了,这里指的是我们要连接的数据库和具体连接操作

Configuration.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2009-2012 the original author or authors. Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. -->
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration>
<!--
<settings>
<setting name="useGeneratedKeys" value="false"/>
<setting name="useColumnLabel" value="true"/>
</settings> <typeAliases>
<typeAlias alias="UserAlias" type="org.apache.ibatis.submitted.complex_property.User"/>
</typeAliases> -->
<environments default="development">
<environment id="development">
<transactionManager type="JDBC">
<property name="" value=""/>
</transactionManager>
<dataSource type="UNPOOLED">
<property name="driver" value="oracle.jdbc.OracleDriver"/>
<property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl"/>
<property name="username" value="practice"/>
<property name="password" value="123"/>
</dataSource>
</environment>
</environments> <mappers>
<mapper resource="config/Student.xml"/>
</mappers> </configuration>

  

现在基本的代码就书写完毕了

演示结果如上图所示!!!

MyBatis 的案例的更多相关文章

  1. Mybatis(综合案例)

    MyBatis本是apache的一个开源项目iBatis,2010年这个项目有Apache software foundation 迁移到了Google code,并改名MyBatis.2013年11 ...

  2. MyBatis入门案例、增删改查

    一.MyBatis入门案例: ①:引入jar包 ②:创建实体类 Dept,并进行封装 ③ 在Src下创建大配置mybatis-config.xml <?xml version="1.0 ...

  3. Spring+springmvc+Mybatis整合案例 annotation版(myeclipse)详细版

    Spring+springmvc+Mybatis整合案例 Version:annotation版 文档结构图: 从底层开始做起: 01.配置web.xml文件 <?xml version=&qu ...

  4. Spring+springmvc+Mybatis整合案例 xml配置版(myeclipse)详细版

    Spring+springmvc+Mybatis整合案例 Version:xml版(myeclipse) 文档结构图: 从底层开始做起: 01.配置web.xml文件 <?xml version ...

  5. MyBatis入门案例 增删改查

    一.MyBatis入门案例: ①:引入jar包 ②:创建实体类 Dept,并进行封装 ③ 在Src下创建大配置mybatis-config.xml <?xml version="1.0 ...

  6. Java基础-SSM之Spring和Mybatis整合案例

    Java基础-SSM之Spring和Mybatis整合案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.   在之前我分享过mybatis和Spring的配置案例,想必大家对它们的 ...

  7. Mybatis入门案例中设计模式的简单分析

    Talk is cheap, show me the code! public class TestMybatis { public static void main(String[] args) t ...

  8. mybatis入门案例自定义实现

    mybatis入门案例自定义实现 一.需要实现的类和接口 public static void main(String[] args) throws Exception{ //1.读取配置文件 Inp ...

  9. mybatis入门案例分析

    mybatis入门案例分析 一.设计模式分析 public class MybatisTest { public static void main(String[] args) throws Exce ...

  10. mybatis升级案例之CRUD操作

    mybatis升级案例之CRUD操作 一.准备工作 1.新建maven工程,和入门案例一样 主要步骤如下,可参考mybatis入门实例 a.配置pom.xml文件 b.新建实例类User.DAO接口类 ...

随机推荐

  1. xld特征

    halcon中什么是xld? xld(eXtended Line Descriptions) 扩展的线性描述,它不是基于像素的,人们称它是亚像素,只不过比像素更精确罢了,可以精确到像素内部的一种描述. ...

  2. 关于 $.proxy(fn,context,arg) 方法

    <!-- $.proxy(fn,this,agrument); proxy 代理 思考做酒的代理商argument就是代理商 把fn所在的作用域对象的参数/属性 代理给fn执行. fn: 要被调 ...

  3. PHP读取文件内容的方法

    下面我们就为大家详细介绍PHP读取文件内容的两种方法. 第一种方法:fread函数 <?php $file=fopen('1.txt','rb+'); echo fread($file,file ...

  4. 洛谷 P1309 瑞士轮 题解

    每日一题 day4 打卡 Analysis 暴力+快排(其实是归并排序) 一开始天真的以为sort能过,结果光荣TLE,由于每次只更改相邻的元素,于是善于处理随机数的快排就会浪费很多时间.于是就想到归 ...

  5. leetcode解题报告(16):Move Zeroes

    描述 Given an array nums, write a function to move all 0's to the end of it while maintaining the rela ...

  6. CSP初赛复习

    初赛复习 初赛一定要过啊,否则付出的那么多都白搭了! while(1) ++csp.rp,++csp.luck,++csp.scores; 历史 2020年开始,除NOIP以外的NOI系列其他赛事(包 ...

  7. Tomcat 解决jvm中文乱码,控制台乱码

    解决方法 打开tomcat/conf/目录 修改logging.properties 找到 java.util.logging.ConsoleHandler.encoding = utf-8 这行 更 ...

  8. 每秒浮点运算次数flops

    每秒浮点运算次数[编辑] 维基百科,自由的百科全书     跳到导航跳到搜索 此条目需要补充更多来源. (2018年2月28日)请协助添加多方面可靠来源以改善这篇条目,无法查证的内容可能会因为异议提出 ...

  9. IDEA中获取资源路径问题

    更正 以src开始,就能用相对路径了... shift+ctrl+alt+s 调出项目结构, 在Modules里,就是设置 Sources Resources Test的界面, 右面的路径就是相对路径 ...

  10. 分布式的一致性(分布式事物)-------2PC详述

    英文名:Two Phase Commit(2PC) 算法目的:实现分布式事物 算法概述: 有两类节点: -----协调者 -----事务参与者 流程阶段: -----请求阶段 -----提交阶段 算法 ...