ibatis 查询异常 Parameter index out of range

<select id="qryUser" resultClass="java.util.HashMap"  parameterClass="java.util.HashMap" >
	SELECT userId  FROM sys_user WHERE 1=1
		<isNotEmpty property="userId">
			AND userId = "#userId#"
		</isNotEmpty>

</select>

以上语句报错了

SqlMapClient operation; SQL [];   \n

--- The error occurred while applying a parameter map.  \n

--- Check the roleManagerSqlMap.qryUserAuthorityIds-InlineParameterMap.  \n

--- Check the parameter mapping for the ‘userId‘ property.  \n

--- Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:   \n

--- The error occurred while applying a parameter map.  \n

--- Check the roleManagerSqlMap.qryUserAuthorityIds-InlineParameterMap.  \n

--- Check the parameter mapping for the ‘userId‘ property.  \n

--- Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).

查了半天,原来是因为

<isNotEmpty property="userId">
			AND userId = "#userId#"
		</isNotEmpty>

这个#userId# 外面多了 双引号, 把双引号去掉好了

时间: 2024-08-08 05:06:17

ibatis 查询异常 Parameter index out of range的相关文章

java.sql.SQLException: Parameter index out of range (0 &lt; 1 )

由于初学写JDBC,所以烦了一个白痴错误,特此记录下来,以期望对寻求同样错误的小伙伴们一个答案,也是自己学习的一个总结记录 该异常的提示错误代码处并不是实际出现错误的代码处. 异常提示为:java.lang.RuntimeException: java.sql.SQLException: Parameter index out of range (0 < 1 ). 原文错误代码为: stmt = conn.prepareStatement("insert into users(name,p

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='nul

Caused by: java.sql.SQLException: Parameter index out of range (1 &gt; number of parameters, which is 0

1.错误描述 org.hibernate.exception.GenericJDBCException: error executing work at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(Sql

Parameter index out of range (1 &gt; number of parameters, which is 0).

数据库错误:Parameter   index   out   of   range   (1   >   number   of   parameters,   which   is   0). 错误发生原因其实很简单,就是当设置参数时,没有相应的问号与之匹配(或者根本就没有?号). 如果是:Parameter   index   out   of   range   (26   >   number   of   parameters,  which   is   25). 翻译为:找到了

mybatis中Parameter index out of range (1 &gt; number of parameters, which is 0).

Parameter index out of range (1 > number of parameters, which is 0).(参数索引超出范围) 在mybatis里面写就是应该是 like  '%${name} %' 而不是 '%#{name} %'   ${name} 是不带单引号的,而#{name} 是带单引号的 所以,当你用到 like '%#{name}%' 会报这种错误 版权声明:本文为不会代码的小白原创文章,未经允许不得转载.

Parameter index out of range(1 &gt; number of parameters, which is 0)参数索引超出范围

今天在写项目的过程中,有一个模块是做多选删除操作,通过servlet获得多选框的value组,然后执行sql操作.如下: 1 @RequestMapping( "/delteCouse.do" ) 2 public void delCouse( HttpServletRequest req, HttpServletResponse resp ) throws SQLException { 3 4 //处理中文 5 try { 6 req.setCharacterEncoding(&qu

jdbcTemplate异常:like模糊查询报错(Parameter index out of range (1 &gt; number of parameters)

http://cuisuqiang.iteye.com/blog/1480525 模糊查询like要这样写 注意Object参数和like语法 public static void main(String[] args) { Object[] para = new Object[]{"%c%"};   List<Object[]> list = excuteQuery("select * from s_user t where t.userName like ?&

ibatis Parameter index out of range (1 &gt; number of parameters, which is 0)

这个错误除了网上常见的like写错之外,这里列出其中一种写法like concat('%', #keyword#, '%'),还有另外的多写单引号什么的以外,今天遇到另一个原因,百度谷歌各种查也没查到,最后才意识到由于我是在navicat中的写好的再粘贴上去的,注释也没删除,删除注释后正常运行.耽误这么一两个小时找原因,坑爹啊!

【Mybatis异常】Caused by: java.sql.SQLException: Parameter index out of range (1 &gt; number of parameters, which is 0).

一.错误原因分析 从错误提示可以看出:实际传入的参数大于sql中待设置的参数,也就是sql中的?少于参数或?根本没有产生原因:  ?号被单引号包围 如: sql += " and article_title like '%#{articleTitle}%'"; 二.解决办法 去掉单引号 上面sql改为: sql += " and article_title like concat('%',#{articleTitle},'%')"; 原文地址:https://www