西湖鱼 发表于 2018-10-24 09:23:00

org.springframework.jdbc.BadSqlGrammarException: CallableStatementCallback; bad

  通过Spring的jdbcTemplate调用Mysql的存储过程,出现下面的问题(以前也使用过,并没有出现下面的问题,折腾大半天,郁闷):
  开始报下面的错误:

  2014-07-01 10:49:15,297 MESSAGE : Loading XML bean definitions from>  2014-07-01 10:49:15,413 MESSAGE : SQLErrorCodes loaded:
  没有更多的错误信息,数据库中也没有反应。然后,通过加入try()catch{}后,可以打印出主要的错误信息如下:
  org.springframework.jdbc.BadSqlGrammarException: CallableStatementCallback; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 '`res`)' at line 1
  根据错误提示,应该是SQL语法错误,但是在Navicat里面执行,没有问题,我就郁闷了。
  创建存储过程语句是,是Navicat工具按步骤创建的:
  CREATE DEFINER=`root`@`localhost` PROCEDURE `huabei_dhqr_id`(OUT 'res' varchar(32))
  后来将参数中的引号去掉,改为:
  CREATE DEFINER=`root`@`localhost` PROCEDURE `huabei_dhqr_id`(OUT res varchar(32))
  可执行成功!

页: [1]
查看完整版本: org.springframework.jdbc.BadSqlGrammarException: CallableStatementCallback; bad