SSM环境下调用mysql存储过程

创建存储过程

CREATE PROCEDURE `sp_name`(IN age VARCHAR(30),OUT num INTEGER)
BEGIN
SELECT * FROM sys_user where sys_user.age > age;
SELECT count(*) into num FROM sys_user;
END

mapper


dao

List selectByAge( Map map );

service

public void findByAge() {
    //参数集合
    Map paramMap = new HashMap<>();
    //入参
    paramMap.put("age", "18");
    //出参,可以不写(如果写,值随意填)
    paramMap.put("num", 1);
    
    List users = baseMapper.selectByAge( map );
    int num = paramMap.get("num");
}

你可能感兴趣的:(SSM环境下调用mysql存储过程)