当前位置:网站首页>模糊查询时报错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('%',?,'%')
边栏推荐
- Counter统计数量后,如何返回有序的key
- [error record] the parameter 'can't have a value of' null 'because of its type, but the im
- [fluent] listview list (map method description of list set | vertical list | horizontal list | code example)
- [Fuhan 6630 encodes and stores videos, and uses RTSP server and timestamp synchronization to realize VLC viewing videos]
- [fluent] futurebuilder asynchronous programming (futurebuilder construction method | asyncsnapshot asynchronous calculation)
- Kubernetes cluster log and efk architecture log scheme
- Deep Reinforcement Learning for Intelligent Transportation Systems: A Survey 论文阅读笔记
- How to limit the size of the dictionary- How to limit the size of a dictionary?
- Use cve-2021-43893 to delete files on the domain controller
- sql server 查询指定表的表结构
猜你喜欢
What does "where 1=1" mean
Deep Reinforcement Learning for Intelligent Transportation Systems: A Survey 论文阅读笔记
I2C 子系统(四):I2C debug
SqlServer行转列PIVOT
Pytest (6) -fixture (Firmware)
HW initial preparation
Installation and use of memory leak tool VLD
[principles of multithreading and high concurrency: 1_cpu multi-level cache model]
Kubernetes cluster log and efk architecture log scheme
Add MDF database file to SQL Server database, and the error is reported
随机推荐
I2C 子系统(二):I3C spec
[C语言]给账号密码进行MD5加密
Global and Chinese ammonium dimolybdate market in-depth analysis and prospect risk prediction report 2022 Edition
Three. JS local environment setup
内存泄漏工具VLD安装及使用
Force freeing memory in PHP
sql server数据库添加 mdf数据库文件,遇到的报错
[shutter] monitor the transparency gradient of the scrolling action control component (remove the blank of the top status bar | frame layout component | transparency component | monitor the scrolling
Add automatic model generation function to hade
Didi programmers are despised by relatives: an annual salary of 800000 is not as good as two teachers
Kubernetes family container housekeeper pod online Q & A?
Super easy to use logzero
Chart. JS multitooltip tag - chart js multiTooltip labels
[Fuhan 6630 encodes and stores videos, and uses RTSP server and timestamp synchronization to realize VLC viewing videos]
Basic operation of binary tree (C language version)
Source code analysis | resource loading resources
Mathematical statistics -- Sampling and sampling distribution
[flutter] example of asynchronous programming code between future and futurebuilder (futurebuilder constructor setting | handling flutter Chinese garbled | complete code example)
Check log4j problems using stain analysis
Kubernetes cluster log and efk architecture log scheme