IDEA_MyBatis_SQLException:Parameter index out of range坑

Posted 小蜗爬爬

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IDEA_MyBatis_SQLException:Parameter index out of range坑相关的知识,希望对你有一定的参考价值。

 

报错信息:超出数据库数据表设定的规定长度了

nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping{property=\'apply_id\', mode=IN, javaType=class java.lang.Object, jdbcType=BIGINT, numericScale=null, resultMapId=\'null\', jdbcTypeName=\'null\', expression=\'null\'}. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #2 with JdbcType BIGINT . Try setting a different JdbcType for this parameter or a different configuration property. Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #2 with JdbcType BIGINT . Try setting a different JdbcType for this parameter or a different configuration property. Cause: java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1

 

 

网上说的解决方案大概如下:

这是占位符的数量 跟 设置的参数数量不相等造成的,检查一下你写的sql和传递的参数吧。

 

特定写like语句所发生的情况:

若是写like语句的时候 ,所用引起的;

在mybatis里面写就是应该是 like  \'%${name} %\' 而不是 \'%#{name} %\'  

注:${name} 是不带单引号的,而#{name} 是带单引号的

***如果是还不是:可能是注释的原因   --这就是我的坑,主要是IDEA还显示好使,不报错,坑爹呀!长记性了!

因为注释加的位置不对!!

 

 

 

 

以上是关于IDEA_MyBatis_SQLException:Parameter index out of range坑的主要内容,如果未能解决你的问题,请参考以下文章