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

一、错误原因分析

从错误提示可以看出:实际传入的参数大于sql中待设置的参数,也就是sql中的?少于参数或?根本没有
产生原因:

 ?号被单引号包围

如:

sql += " and article_title like ‘%#{articleTitle}%‘";

二、解决办法

去掉单引号

上面sql改为:

sql += " and article_title like concat(‘%‘,#{articleTitle},‘%‘)";

原文地址:https://www.cnblogs.com/756623607-zhang/p/11148752.html

时间: 2024-08-29 01:46:05

【Mybatis异常】Caused by: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).的相关文章

Caused by: java.sql.SQLException: Parameter index out of range (1 > 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

java.sql.SQLException: Parameter index out of range (0 < 1 )

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

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

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). 翻译为:找到了

org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback.....Parameter index out of range (1 &gt; number of parameters, which is 0).;

sql有误,一般是   sql语句少了问号.

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

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

异常——Caused by: java.sql.SQLException: ORA-00911: 无效字符

今天写一个sql语句在navicat测试没有问题,在mybatis运行报这个错,百度了一下,sql语句末尾多了个分号 ";",去掉即可. 版权声明:本文为博主原创文章,未经博主允许不得转载.

java.sql.SQLException:Column Index out of range,0&lt;1

1.错误描述 2.错误原因 try { Class.forName("com.mysql.jdbc.Driver"); Connection conn = null; Statement stat = null; ResultSet rs = null; try { conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/school", "root", "root