• mybatis 调用存储过程


    第一步,在oracle数据库中创建存储过程
    create or replace procedure pro_test(ename varchar2,
    result out varchar2
    )
    as
    begin
    result:='hello,'||ename;
    end;
    第二步,在dao接口中声明调用存储过程的方法
    第三步,在mapper中实现该方法
    第四步,测试
    /**
    * 调用存储过程
    */
    public class Test04 {
    public static void main(String[] args) {
    SqlSession session = SqlSessionFactoryUtil.getSession();
    EmpDao empDao = session.getMapper(EmpDao.class);
    //声明Map
    Map<String,Object> map = new HashMap<String,Object>();
    //传递入参
    map.put("ename","zhangsan");
    //设置出参,出参的值暂时设置为null
    map.put("result",null);
    //调用存储过程
    empDao.testPro(map);
    //存储过程调用之后,map中的出参就有值了
    System.out.println("result:"+map.get("result"));
    session.close();
    }
    }
  • 相关阅读:
    Spark Streaming ---没用
    spark-streaming笔记 ---没用
    zookeeper笔记 ---没用
    远程调试笔记 ---没用
    远程仓库
    git之时光机穿梭
    分布式版本控制系统 VS 集中式
    Map与WeakMap
    set与weakset
    Genarator生成器
  • 原文地址:https://www.cnblogs.com/duguangming/p/10889625.html
Copyright © 2020-2023  润新知