IBatis调用MySQL存储过程出错,谁先解决分就是谁的
1个回答
展开全部
ibatis.xml:
<parameterMap id="testParamMap" class="java.util.Map">
<parameter property="username" jdbcType="string" javaType="java.lang.String" mode="IN" />
<parameter property="operateResult" jdbcType="INT" javaType="java.lang.Integer" mode="OUT" />
</parameterMap>
<procedure id="testProc" parameterMap="testParamMap" >
{CALL mytest (?,?)}
</procedure>
java里面调用:
Integer operateResult = null;
HashMap paramMap = new HashMap();
paramMap.put("username", userVO.getUsername());
paramMap.put("operateResult", operateResult);
Object obj = testDao.queryForObject("test.testProc", paramMap);
存储过程: (存储过程在MYSQL 调用成功了)
DELIMITER $$
DROP PROCEDURE IF EXISTS `mytest`$$
USE `aa`$$
CREATE DEFINER=`root`@`192.168.1.46` PROCEDURE `mytest`(inname VARCHAR(20), OUT returnid INTEGER(11))
BEGIN
SELECT u.user_id FROM user u WHERE u.user_name=inname;
END$$
DELIMITER;
<parameterMap id="testParamMap" class="java.util.Map">
<parameter property="username" jdbcType="string" javaType="java.lang.String" mode="IN" />
<parameter property="operateResult" jdbcType="INT" javaType="java.lang.Integer" mode="OUT" />
</parameterMap>
<procedure id="testProc" parameterMap="testParamMap" >
{CALL mytest (?,?)}
</procedure>
java里面调用:
Integer operateResult = null;
HashMap paramMap = new HashMap();
paramMap.put("username", userVO.getUsername());
paramMap.put("operateResult", operateResult);
Object obj = testDao.queryForObject("test.testProc", paramMap);
存储过程: (存储过程在MYSQL 调用成功了)
DELIMITER $$
DROP PROCEDURE IF EXISTS `mytest`$$
USE `aa`$$
CREATE DEFINER=`root`@`192.168.1.46` PROCEDURE `mytest`(inname VARCHAR(20), OUT returnid INTEGER(11))
BEGIN
SELECT u.user_id FROM user u WHERE u.user_name=inname;
END$$
DELIMITER;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询