求助java调用存储过程,报错:Parameter number 2 is not an OUT parameter

William_Wei007 William_Wei007 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
代码如下:

存储过程:
create PROCEDURE get_redbag_name(in p_id int ,out p_name VARCHAR(50))
begin
select name from qb_redbag_ticket where id = p_id into p_name ;
end ;



java mapper.xml调用方式:
<select id="findById" statementType="CALLABLE" parameterMap="homeVO">
{call get_redbag_name(?,?)}
</select>

<parameterMap type="map" id="homeVO">
<parameter property="p_id" jdbcType="INTEGER" mode="IN"/>
<parameter property="p_name" jdbcType="VARCHAR" mode="OUT"/>
</parameterMap>



dao层:

public  List<Map> findById(Map pram);



biz层:
public  void findById(Map pram){
setDb(0, MASTER);
redbagTicketDao.findById(pram);
}


service:
public void  findById(Map bo){
redbagTicketBiz.findById(bo);
System.out.println(bo.get("p_name"));
}


rest层:

@SuppressWarnings({ "rawtypes", "unchecked" })
@RequestMapping(value = "/findById", method = RequestMethod.POST)
public Map queryRd(@RequestBody Map bo) {
log.debug("查询红包lname--" + JSON.toJSONString(bo));
try {
LinkedHashMap linkedHashMap = new LinkedHashMap();
redbagTicketService.findById(bo);
return super.returnSuccessInfo(linkedHashMap);
} catch (Exception e) {
log.error("异常信息- 查询红包name--系统异常:" + JSON.toJSONString(bo), e);
return super.returnFailtrueInfo(e);
}
}



test案例为:
@Test
public void findById(){

uri = "http://localhost:8080/front.onigiri/redbag/findById";

Map map = new HashMap<>();

map.put("p_id", 198898);
map.put("p_name", "");

RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.parseMediaType("application/json; charset=utf-8"));
headers.set("Accept-Charset", "UTF-8");
HttpEntity entity = new HttpEntity(JSON.toJSONString(map),headers);
ResponseEntity response = restTemplate.exchange(uri,HttpMethod.POST, entity, Map.class);
LinkedHashMap responseMap = (LinkedHashMap)response.getBody();
System.out.print(responseMap);
assertTrue(true);

}



已排查信息:
1、数据库中有存储过程。
2、存储过程名称无错
3、已设置了权限:
 grant select,insert,update,delete  on fantuan.* to root@'localhost' identified by 'xxx';

grant execute on procedure fantuan.get_redbag_name to root@'localhost' identified by 'xxx';

grant select on mysql.proc to root@'localhost' identified by 'xxx';


FLUSH PRIVILEGES ;


4、链接数据库的位置也增加了 noAccessToProcedureBodies=true

以上方式都尝试了。依然错误。请各位知晓的朋友深处援助之手吧。谢谢啦
...全文
评论 3
收藏 已收藏
分享
返回顶部
William_Wei007
Java EE 67,535 成员 225,843 内容