jdbc在模糊搜索时候报错:Parameter index out of range
源代码如下
String sql = "select g.id,g.goodsname,g.price,g.offset,g.time,g.counts,g.cid from goods g,(select g1.id, concat(g1.goodsname,c1.cname) words "
+ "from goods g1,category c1) t where words like '%?%' and t.id = g.id order by g.id limit ?,? ;";报错问题如下
Parameter index out of range (3 > number of parameters, which is 2).修改如下
String sql = "select g.id,g.goodsname,g.price,g.offset,g.time,g.counts,g.cid from goods g,(select g1.id, concat(g1.goodsname,c1.cname) words "
+ "from goods g1,category c1) t where words like concat('%',?,'%') and t.id = g.id order by g.id limit ?,? ;";

本文介绍了一种常见的JDBC模糊查询时出现的Parameterindexoutofrange错误,并提供了具体的解决方案,通过调整SQL语句中参数的位置来修复该问题。
1489

被折叠的 条评论
为什么被折叠?



