zoukankan      html  css  js  c++  java
  • 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还显示好使,不报错,坑爹呀!长记性了!

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

     

     

  • 相关阅读:
    053-1
    多项式ADT笔记(数据结构c版)
    052-188
    052-187
    052-186
    052-185
    052-184
    052-183
    052-182
    JS中的垃圾回收(GC)
  • 原文地址:https://www.cnblogs.com/zhaojinxin/p/7295278.html
Copyright © 2011-2022 走看看