1个回答
展开全部
给你个我写的真实案例步骤,如果实用,记得给点分哦。嘿嘿
mybatis调用存储过程:
第一步:mapper.xml文件调用过程名:
<resultMap type="java.util.HashMap" id="outOfMap">
<result column="nID" property="nID" jdbcType="DECIMAL" />
<result column="nError" property="nError" jdbcType="DECIMAL"/>
<result column="sCode" property="sCode" jdbcType="VARCHAR"/>
<result column="nNum" property="nNum" jdbcType="DECIMAL"/>
</resultMap>
<select id="getIDAndError" statementType="CALLABLE"
parameterType="java.util.HashMap" resultMap="outOfMap">
{call exam_getid (
#{sCode,mode=IN,jdbcType=VARCHAR},
#{nNum,mode=IN,jdbcType=DECIMAL},
#{nID,mode=OUT,jdbcType=DECIMAL},
#{nError,mode=OUT,jdbcType=DECIMAL}
)
}
</select>
第二步:mapper.java文件调用方法:
public HashMap<String, Object> getIDAndError(HashMap<String, Object> map);
第三步:传参数和获取结果的调用:
HashMap<String, Object> parms = new HashMap<String, Object>();
parms.put("sCode", "exam");
parms.put("nNum", 1);
prdpmsSequenceMapper.getIDAndError(parms);
//System.out.println(parms.get("nID"));
int id;
String nID = parms.get("nID").toString();
id = Integer.valueOf(nID);
mybatis调用存储过程:
第一步:mapper.xml文件调用过程名:
<resultMap type="java.util.HashMap" id="outOfMap">
<result column="nID" property="nID" jdbcType="DECIMAL" />
<result column="nError" property="nError" jdbcType="DECIMAL"/>
<result column="sCode" property="sCode" jdbcType="VARCHAR"/>
<result column="nNum" property="nNum" jdbcType="DECIMAL"/>
</resultMap>
<select id="getIDAndError" statementType="CALLABLE"
parameterType="java.util.HashMap" resultMap="outOfMap">
{call exam_getid (
#{sCode,mode=IN,jdbcType=VARCHAR},
#{nNum,mode=IN,jdbcType=DECIMAL},
#{nID,mode=OUT,jdbcType=DECIMAL},
#{nError,mode=OUT,jdbcType=DECIMAL}
)
}
</select>
第二步:mapper.java文件调用方法:
public HashMap<String, Object> getIDAndError(HashMap<String, Object> map);
第三步:传参数和获取结果的调用:
HashMap<String, Object> parms = new HashMap<String, Object>();
parms.put("sCode", "exam");
parms.put("nNum", 1);
prdpmsSequenceMapper.getIDAndError(parms);
//System.out.println(parms.get("nID"));
int id;
String nID = parms.get("nID").toString();
id = Integer.valueOf(nID);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询