MyBatis:MyBatis操作MySQL存储过程
2024-08-26 11:47:26
一 . 数据库中创建存储过程,并查看创建结果
1.创建存储过程
DROP procedure IF EXISTS net_procedure_request;
DELIMITER $$
CREATE procedure net_procedure_request(in select_type varchar(99))
BEGIN
IF select_type='' THEN
select client_ip,request_size_all,from_unixtime(start_time,'%Y年%m月%d日-%H时:%i分:%S秒') as startTime from net_table_request;
ELSEIF select_type='' THEN
select client_ip,request_size_all,from_unixtime(start_time,'%Y年%m月%d日-%H时:%i分') as startTime from net_table_request;
ELSEIF select_type='' THEN
select client_ip,request_size_all,from_unixtime(start_time,'%Y年%m月%d日-%H时') as startTime from net_table_request;
END IF;
END$$
DELIMITER ;
2.查看创建存储过程结果
show procedure status;
3.导出创建存储过程的语句
show create procedure net_procedure_request;
4.数据库调用存储过程
set @select_type='';
call net_procedure_request(@select_type);
二 . MyBatis中调用存储过程
<select id="getInfo" statementType="CALLABLE" resultMap="infoResultMap" parameterType="java.util.HashMap">
{call net_procedure_request(#{select_type,mode=IN,jdbcType=VARCHAR},#{client_ip,mode=IN,jdbcType=VARCHAR})}
</select>
注意:select标签中一定要加《statementType=“CALLABLE”》。
最新文章
- LinkedHashMap及其源码分析
- python--文件删除、判断目录存在、字符串替换
- Mysql5.7版本编译安装及配置
- PHP基础16:多维数组
- 编译busybox-1.24.1 制作文件系统
- 利用Nginx+Mono+Fastcgi代替IIS对Asp.Net进行反向代理
- Flex 列表控件中的操作
- css 所有选择器
- 在虚拟机的linux中利用VMware Tools实现与windows共享文件
- CSAPP:Binary Bomb
- poj2484--A Funny♂Game
- Libev学习笔记4
- 青云B轮获2000万美元VC的背后逻辑:用技术超越巨头
- Android5.1源码Xposed框架编译
- python爬虫实战 获取豆瓣排名前250的电影信息--基于正则表达式
- LeetCode 单链表专题 (一)
- fatal error LNK1120: 11 unresolved externals
- 事件Event实现消费者模型
- Monent.js:强大的日期处理类库
- 6.翻译:EF基础系列---什么是EF中的实体?
热门文章
- jeecg的开发api接口之旅(http)
- 装新的python3.7时ModuleNotFoundError: No module named &#39;_ctypes&#39;
- binlog2sql安装
- 最新my.cnf可用于5.6&;5.7
- pip---cannot import name main解决方案
- 关于bat文件的批处理
- 2019-ACM-CCPC-Online-Contest
- wireshark 抓包再利用TCP socket发送包里的payload是可以实现登陆的
- LGOJP2831 愤怒的小鸟
- mysql 杂记 —— 时区问题