当前位置:网站首页>模糊查询时报错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('%',?,'%')
边栏推荐
- [hcia]no.15 communication between VLANs
- Baidu map - surrounding search
- Unity3d human skin real time rendering real simulated human skin real time rendering "suggestions collection"
- Thunderbolt Chrome extension caused the data returned by the server JS parsing page data exception
- Apple releases MacOS 11.6.4 update: mainly security fixes
- Your family must be very poor if you fight like this!
- [translation] flux is safe. Gain more confidence through fuzzy processing
- TCP 三次握手和四次挥手机制,TCP为什么要三次握手和四次挥手,TCP 连接建立失败处理机制
- Sqlserver row to column pivot
- Linear rectification function relu and its variants in deep learning activation function
猜你喜欢

Three. JS local environment setup

Le processus de connexion mysql avec docker

SqlServer行转列PIVOT

Practice of traffic recording and playback in vivo

I2C 子系統(四):I2C debug

Practice of traffic recording and playback in vivo

力扣------网格中的最小路径代价

Choose it when you decide

I2C 子系统(四):I2C debug

Today, it's time to copy the bottom!
随机推荐
Yiwen takes you to know ZigBee
Kubernetes cluster log and efk architecture log scheme
Xiaodi notes
Change cell color in Excel using C - cell color changing in Excel using C
Distributed transaction
Source code analysis | layout file loading process
Practice of traffic recording and playback in vivo
MUX VLAN Foundation
Cancer biopsy instruments and kits - market status and future development trends
Thunderbolt Chrome extension caused the data returned by the server JS parsing page data exception
[shutter] banner carousel component (shutter_wiper plug-in | swiper component)
Andwhere multiple or query ORM conditions in yii2
js根据树结构查找某个节点的下面的所有父节点或者子节点
Mathematical statistics -- Sampling and sampling distribution
HW initial preparation
超好用的日志库 logzero
C语言中左值和右值的区别
Can netstat still play like this?
C language beginner level - pointer explanation - paoding jieniu chapter
Force freeing memory in PHP