当前位置:网站首页>模糊查詢時報錯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('%',?,'%')
边栏推荐
- Variable declarations following if statements
- Creation and destruction of function stack frame
- 二维格式数组格式索引下标连续问题导致 返回json 格式问题
- Can netstat still play like this?
- 用docker 連接mysql的過程
- How to return ordered keys after counter counts the quantity
- "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
- Build a private cloud disk cloudrev
- Check log4j problems using stain analysis
- Joking about Domain Driven Design (III) -- Dilemma
猜你喜欢
C language beginner level - pointer explanation - paoding jieniu chapter
Creation and destruction of function stack frame
HTB-Devel
[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
Sqlserver row to column pivot
TCP handshake three times and wave four times. Why does TCP need handshake three times and wave four times? TCP connection establishes a failure processing mechanism
ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc
分布式事务
Left connection, inner connection
I2C 子系統(四):I2C debug
随机推荐
Update and return document in mongodb - update and return document in mongodb
[error record] the parameter 'can't have a value of' null 'because of its type, but the im
Linear rectification function relu and its variants in deep learning activation function
【Flutter】shared_ Preferences local storage (introduction | install the shared_preferences plug-in | use the shared_preferences process)
Today, it's time to copy the bottom!
The process of connecting MySQL with docker
[C语言]给账号密码进行MD5加密
Chart. JS multitooltip tag - chart js multiTooltip labels
左连接,内连接
Introduction to cron expression
Pytest (6) -fixture (Firmware)
Pytest (6) -fixture (Firmware)
基于can总线的A2L文件解析(2)
Force deduction ----- the minimum path cost in the grid
sql server 查询指定表的表结构
yii2 中andWhere多个or查询 orm条件
Use cve-2021-43893 to delete files on the domain controller
ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc
TCP 三次握手和四次挥手机制,TCP为什么要三次握手和四次挥手,TCP 连接建立失败处理机制
Deep learning: multi-layer perceptron and XOR problem (pytoch Implementation)