当前位置:网站首页>模糊查詢時報錯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('%',?,'%')
边栏推荐
- Concrete CMS vulnerability
- [translation] modern application load balancing with centralized control plane
- sql server数据库添加 mdf数据库文件,遇到的报错
- Privatization lightweight continuous integration deployment scheme -- 01 environment configuration (Part 2)
- I2C 子系统(三):I2C Driver
- MUX VLAN Foundation
- Add some hard dishes to the interview: how to improve throughput and timeliness in delayed task scenarios!
- [fluent] JSON model conversion (JSON serialization tool | JSON manual serialization | writing dart model classes according to JSON | online automatic conversion of dart classes according to JSON)
- C语言中左值和右值的区别
- I2C 子系统(一):I2C spec
猜你喜欢
Three. JS local environment setup
左连接,内连接
C language beginner level - pointer explanation - paoding jieniu chapter
Deep learning: multi-layer perceptron and XOR problem (pytoch Implementation)
从C到Capable-----利用指针作为函数参数求字符串是否为回文字符
超好用的日志库 logzero
Add some hard dishes to the interview: how to improve throughput and timeliness in delayed task scenarios!
用docker 連接mysql的過程
[principles of multithreading and high concurrency: 1_cpu multi-level cache model]
Matlab tips (24) RBF, GRNN, PNN neural network
随机推荐
Error when installing MySQL in Linux: starting mysql The server quit without updating PID file ([FAILED]al/mysql/data/l.pid
Cancer biopsy instruments and kits - market status and future development trends
力扣------网格中的最小路径代价
[Fuhan 6630 encodes and stores videos, and uses RTSP server and timestamp synchronization to realize VLC viewing videos]
Strategy application of Dameng database
Add some hard dishes to the interview: how to improve throughput and timeliness in delayed task scenarios!
TCP 三次握手和四次挥手机制,TCP为什么要三次握手和四次挥手,TCP 连接建立失败处理机制
The solution of "the required function is not supported" in win10 remote desktop connection is to modify the Registry [easy to understand]
[fluent] JSON model conversion (JSON serialization tool | JSON manual serialization | writing dart model classes according to JSON | online automatic conversion of dart classes according to JSON)
Left connection, inner connection
Didi programmers are despised by relatives: an annual salary of 800000 is not as good as two teachers
Today, it's time to copy the bottom!
What does "where 1=1" mean
A2L file parsing based on CAN bus (2)
Change cell color in Excel using C - cell color changing in Excel using C
Summary of interview project technology stack
[shutter] bottom navigation bar page frame (bottomnavigationbar bottom navigation bar | pageview sliding page | bottom navigation and sliding page associated operation)
Distributed transaction
leetcode540
MUX VLAN Foundation