首先我们需要先下载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. List<Map<String, Obejct>>遍历

    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); Map&l ...

  2. 基于JSON的接口测试框架

    更多学习资料请加QQ群: 822601020获取 实现效果 需求场景: 公司微服务接口使用数字签名的方式, 使用Postman调试接口每次都需要修改源码将验签临时关闭, 但是关闭后,其他微服务不能正常 ...

  3. java 封装返回结果实体类 返回结果以及错误信息

    public class ResponseMessage { private final static String STATUS_OK = "0"; private final ...

  4. (转载) 添加或删除datanode节点

    转载:https://www.cnblogs.com/marility/p/9362168.html 1.测试环境 ip 主机名 角色 10.124.147.22 hadoop1 namenode 1 ...

  5. meshing-八分之一圆球

    ​原视频下载地址:https://yunpan.cn/cqwiFDCg6PbFj  访问密码 d1c8

  6. @AUTORELEASEPOOL

    Swift 在内存管理上使用的是自动引用计数 (ARC) 的一套方法,在 ARC 中虽然不需要手动地调用像是 retain,release 或者是 autorelease 这样的方法来管理引用计数,但 ...

  7. IIS Express(电脑无管理员权限如何启用VS调试)

    转载页面:https://www.cnblogs.com/xbblogs/p/4756552.html(详细版)  直接按照红色字体步骤执行,其他字体可先忽略 出问题再详细看   1.设置配置文件   ...

  8. RESTful入门

    RESTful入门 1. REST简介 和RPC一样,都是目前比较主流的URL链接风格,也可以说是web服务的一种架构风格.REST全称Representational State Transfer, ...

  9. 从结构到性能,一文概述XGBoost、Light GBM和CatBoost的同与不同

    尽管近年来神经网络复兴并大为流行,但是 boosting 算法在训练样本量有限.所需训练时间较短.缺乏调参知识等场景依然有其不可或缺的优势.本文从算法结构差异.每个算法的分类变量时的处理.算法在数据集 ...

  10. API 设计 POSIX File API

    小结: 1. https://mp.weixin.qq.com/s/qWrSyzJ54YEw8sLCxAEKlA API 设计最佳实践的思考 谷朴 阿里技术 昨天   阿里妹导读:API 是模块或者子 ...