当前位置:网站首页>模糊查询时报错Parameter index out of range (1 > number of parameters, which is 0)
模糊查询时报错Parameter index out of range (1 > number of parameters, which is 0)
2022-07-03 02:56:00 【一尾流鸢cd】
以下为报错信息
select * from user where uid like '%?%'
java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at com.mysql.jdbc.PreparedStatement.checkBounds(PreparedStatement.java:3288)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3272)
at com.mysql.jdbc.PreparedStatement.setInternal(PreparedStatement.java:3314)
at com.mysql.jdbc.PreparedStatement.setInt(PreparedStatement.java:3258)
at com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:3533)
预编译赋值可能出现的错误:
- 指定的赋值位置错误,即
parameterIndex参数错误,此参数的值是从1开始- 赋值数量不够
在保证sql语句没有错误,且使用预编译赋值无错误的情况下:
…
有可能是sql语句中使用的字符拼接方式不正确,小编就是这样,刚开始使用单引号发生上面所述的异常。
解决方法:
改变sql语句的拼接方式,小编改成了select * from user where uid like concat('%',?,'%')
边栏推荐
- Sous - système I2C (IV): débogage I2C
- C语言中左值和右值的区别
- Notifydatasetchanged not applicable to recyclerview - notifydatasetchanged not working on recyclerview
- Matlab tips (24) RBF, GRNN, PNN neural network
- [fluent] listview list (map method description of list set | vertical list | horizontal list | code example)
- Reset or clear NET MemoryStream - Reset or Clear . NET MemoryStream
- sql server 查询指定表的表结构
- I2C subsystem (III): I2C driver
- Change cell color in Excel using C - cell color changing in Excel using C
- Force deduction ----- the minimum path cost in the grid
猜你喜欢

Add MDF database file to SQL Server database, and the error is reported

C语言初阶-指针详解-庖丁解牛篇

Today, it's time to copy the bottom!

SQL statement

What does "where 1=1" mean

"Analysis of 43 cases of MATLAB neural network": Chapter 43 efficient programming skills of neural network -- Discussion Based on the characteristics of the new version of MATLAB r2012b

random shuffle注意

Basic operation of binary tree (C language version)

Check log4j problems using stain analysis

Baidu map - surrounding search
随机推荐
Apple releases MacOS 11.6.4 update: mainly security fixes
[translation] modern application load balancing with centralized control plane
Practice of traffic recording and playback in vivo
Build a private cloud disk cloudrev
Informatics Olympiad one general question bank 1006 a+b questions
As a leader, how to control the code version and demand development when the epidemic comes| Community essay solicitation
How to select the minimum and maximum values of columns in the data table- How to select min and max values of a column in a datatable?
从C到Capable-----利用指针作为函数参数求字符串是否为回文字符
Add some hard dishes to the interview: how to improve throughput and timeliness in delayed task scenarios!
I2C 子系统(一):I2C spec
SqlServer行转列PIVOT
MATLAB小技巧(24)RBF,GRNN,PNN-神经网络
I2C 子系统(三):I2C Driver
The core idea of performance optimization, dry goods sharing
What does it mean when lambda is not entered?
Today, it's time to copy the bottom!
What is the way out for children from poor families?
ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc
内存泄漏工具VLD安装及使用
Opengauss database development and debugging tool guide