MyBatis 调用 Mysql 的存储过程 报错 !
存储过程:
CREATE DEFINER=`root`@`%` PROCEDURE `aaa`(
IN pono VARCHAR ( 50 ),
IN heatNo VARCHAR ( 50 ),
IN stNo VARCHAR ( 50 ),
IN stSampleNo VARCHAR ( 50 ),
IN wholeBacklogCode VARCHAR ( 50 ),
IN beginTime datetime,
IN endinTime datetime
)
BEGIN
~~~~~~~~~~
END;
存储过程运行没有任何问题。
mybatis:
<select id="select4" parameterType="java.util.Map" resultType="Map" statementType="CALLABLE" >
{call aaa(#{pono,jdbcType=VARCHAR}, #{heatNo,jdbcType=VARCHAR}, #{stNo,jdbcType=VARCHAR}, #{stSampleNo,jdbcType=VARCHAR}, #{wholeBacklogCode,jdbcType=VARCHAR}, #{beginTime,jdbcType=TIMESTAMP}, #{endinTime,jdbcType=TIMESTAMP})}
</select>
运行后报错:
Error querying database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CALL aaa(null, null, null, null, null, null, null)) tmp_count' at line 1 ### The error may exist in file [E:\WebMes\lx_mes_service\lx_spes\target\classes\mybatis\TQmtS25WorkproceMapper.xml] ### The error may involve com.aaa.mapperMapper.select4-Inline ### The error occurred while setting parameters ### SQL: select count(0) from ({call aaa(?, ?, ?, ?, ?, ?, ?)}) tmp_count ### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CALL aaa(null, null, null, null, null, null, null)) tmp_count' at line 1 ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CALL aaa(null, null, null, null, null, null, null)) tmp_count' at line 1
把我搞崩溃啦,才学了半个月就上战场.