Wrong number of parameters: expected 0, was given 1 Query: select count(*) from product where pname like '%?%' Parameters: [%小%]

eclipse在dao层写的模糊查询sql:String sql = "select count(*) from product where pname like ‘%?%‘";

这样写会导致以下错误

Wrong number of parameters: expected 0, was given 1 Query: select count(*) from product where pname like ‘%?%‘ Parameters: [%小%]<br/>

原因:

系统并没有把sql里面的语句当成占位符?,只是当成了普通的字符。

如果在其他sql遇到这样的报错,

检查sql需要的参数个数(expected 0)和传递的参数个数(was given 1)是否一致

解决方法:

将sql改成:String sql = "select count(*) from product where pname like ?";

然后将被占位的参数用 "%"+参数+"%"拼接作为模糊查询的条件<br/>

保证sql需要参数数量和给出的参数数量一致

Wrong number of parameters: expected 0, was given 1 Query: select count(*) from product where pname like '%?%' Parameters: [%小%]

原文地址:https://www.cnblogs.com/chengjianJava/p/12207987.html

时间: 2024-10-10 14:46:20

Wrong number of parameters: expected 0, was given 1 Query: select count(*) from product where pname like '%?%' Parameters: [%小%]的相关文章

java.sql.SQLException: Cannot create com._51doit.pojo.User: com._51doit.pojo.User Query: select * from user where username = ? and password = ? Parameters: [AA, 123]

在从数据库中查询数据,并存入javabean中去时,报这个错误 原因:在建立User类去存储信息时没有创建无参构造方法,创建一个无参构造方法即可 原文地址:https://www.cnblogs.com/jj1106/p/11624765.html

Tomcat发布程序时遇到Cannot create org.apache.catalina.User: org.apache.catalina.User Query: select * from user where name = ? and pwd = ? Parameters: [*,*]

问题如题所示,报错截图 此段代码已经经过测试是不存在问题的,但是当写到servlet中发布的时候就遇上了这个问题,问题字面意思是不能创建domain中的实体类User. 我一开始发现user类导入的不是自己写的domain,而是误把apache里的user类导入了,修改之后发现还是出现这个报错: 但是在仔细观察报错文字和代码之后,觉得说的就是类导错了,于是重启eclipse,问题解决?????WTF??????? 原文地址:https://www.cnblogs.com/CptMac/p/123

Error Code: 1318. Incorrect number of arguments for PROCEDURE student.new_procedure; expected 0, got

1.错误描述 13:58:20 call new_procedure('2000','zhangsan') Error Code: 1318. Incorrect number of arguments for PROCEDURE student.new_procedure; expected 0, got 2 0.000 sec 2.错误原因 CREATE DEFINER=`root`@`localhost` PROCEDURE `new_procedure`() BEGIN set @a=1

编绎报错,解决方法objc_msgSend too many arguments to function call,expected 0, have3 (转)

  编绎报错,objc_msgSend too many arguments to function call,expected 0, have3 解决方法:  

Too many arguments to function call, expected 0, have 5

报错位置 SDWebImage里面一些类的方法 objc_msgSend(delegate, @selector(webImageManager:didFinishWithImage:forURL:), self, image, url); 报错内容 ......SDWebImage/SDWebImageManager.m:246:22: Too many arguments to function call, expected 0, have 5 解决方法 选Build Settings,将

xcode6 使用MJRefresh,Too many arguments to function call, expected 0, have *

转载自:  http://blog.csdn.net/wsjshx/article/details/40743291 将XCode升级到6后,报Too many arguments to function call, expected 0, have *,在XCode5.1里能编译通过的,到xcode6就报错 objc_msgSend(self.beginRefreshingTaget, self.beginRefreshingAction, self); Too many arguments

Too many arguments to function call ,expected 0,have3

使用MJRefresh上拉加载,下拉刷新时,导入包后,编译出现:Too many arguments to function call ,expected 0,have3 网上解决解决办法: Build Setting--> Apple LLVM 6.0 - Preprocessing--> Enable Strict Checking of objc_msgSend Calls  将YES 改为 NO

解决Parameter &#39;offset&#39; not found. Available parameters are [0, 1, param1, param2]的方法

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'offset' not found. Available parameters are [0, 1, param1, param2] at org.mybatis.spring.MyBatisExceptionTranslator.translateExcepti

Parameter &#39;email&#39; not found. Available parameters are [0, 1, param1, param2]解决方案

转自:https://blog.csdn.net/wdehxiang/article/details/77619569 原因: 传入多个值时,mybatis会自动将这些值转成类似map形式的值,以0,1,2…的序列为keyName. 这里我们需要先简单了解一下mybatis的传值机制.Mybatis现在可以使用的parameterType有基本类型和Java负责类型 基本数据类型:包含int,String,Date等.基本数据类型作为传参,只能传入一个.通过#{参数名}获取. 复杂数据类型:包含