(1)错误描述:这个错误大概是说需要的参数是一个,而你传入了两个参数,导致了参数变多抛异常
2019-03-28 09:05:09.375 ERROR 287527 --- [nio-1601-exec-2] o.s.b.w.servlet.support.ErrorPageFilter : Forwarding to error page from request [/isvSearch/getSearchManagerInfoList] due to exception [nested exception is org.apache.ibatis.type.TypeException:
Could not set parameters for mapping: ParameterMapping{property='venderId', mode=IN, javaType=class java.lang.Object, jdbcType=null, numericScale=null, resultMapId='null', jdbcTypeName='null', expression='null'}.
Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #2 with JdbcType null . 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 null .
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:
Preparing: SELECT DISTINCT app_key,channel_name FROM sms_channel
WHERE ((entity_code = concat('B','?')) OR (entity_code = concat('P','?')))AND app_key=?
日志打印入参:
查询ISV名称入参:venderId=6****2,appId=3FA3B5D**************D6C6215C6EE4
(2)错误解决
出现这种问题的最本质原因在入参跟需要传入的参数个数不一致,导致出现类似错误,多了少了的。
这时候我们应该先定位到相应位置,我这边入参传入的是String类型的,然后我在mybaits取入参的时候又加了一层引号导致它未检测到,传入两个参数而只有一个坑位,所以报错了。
原错误sql:
@Select(
"")
改正后sql:
@Select(
"")