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还显示好使,不报错,坑爹呀!长记性了!

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

 

 

 

 

转载于:https://www.cnblogs.com/zhaojinxin/p/7295278.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值