使用sqls.create执行带出参的存储过程,出参为中文,使用sql.getOutParams出参显示为乱码,求助该怎么解决
6 回复
Sql sql = Sqls.create("CALL PRO_RECEIVE_" + stBusCode + "(@stReservationNum,@nmInsertUser,@OUTresult,@OUTnmRecId,@OUTerrorMessage)");
sql.params().set("stReservationNum", stReservationNum);
sql.params().set("nmInsertUser", UserUtils.getUserIdFromSession(session));
sql.params().set("OUTresult", Types.VARCHAR);
sql.params().set("OUTnmRecId", Types.INTEGER);
sql.params().set("OUTerrorMessage", Types.VARCHAR);
dao.execute(sql);
Record re = sql.getOutParams();
String result = "N";
if(re.get("result") != null){
if("Y".equals(re.get("result"))){
//存储过程执行成功
result = "Y";
Integer nmRecId = Integer.valueOf((String) re.get("nmRecId"));
map.put("nmRecId", nmRecId);
}else{
//存储过程执行失败
String errorMessage = String.valueOf(re.get("errorMessage"));
map.put("errorMessage", errorMessage);
}
}
添加回复
请先登陆