sql 语句select * from news where keyWords like'%?%'如何传值给?
如题,ps=ct.prepareStatement("select*fromnewswherekeyWordslike'%?%'");ps.setString(1,sea...
如题,
ps = ct.prepareStatement("select * from news where keyWords like'%?%'");
ps.setString(1, search);
rs = ps.executeQuery();
这里会报错说Parameter index out of range (1 > number of parameters, which is 0).不能传参,也就是说sql语句吧?直接作为字符去表里面查询了,谁有比较好的方法可以传参数进like里面么? 展开
ps = ct.prepareStatement("select * from news where keyWords like'%?%'");
ps.setString(1, search);
rs = ps.executeQuery();
这里会报错说Parameter index out of range (1 > number of parameters, which is 0).不能传参,也就是说sql语句吧?直接作为字符去表里面查询了,谁有比较好的方法可以传参数进like里面么? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询