how to implement like operator in prepared statement? [duplicate]

╄→гoц情女王★ 提交于 2020-01-11 10:44:24

问题


ps=con.prepareStatement("select * from REGISTER inner join ORGAN on REGISTER.PATIENTID=ORGAN.PATIENTID where ORGAN.ORGAN LIKE ?");          
ps.setString(1,"'%"+o.getOrgan()+"%'");

I executed the query in SQL Developer which works fine, but in DAO class it is not returning any result set.


回答1:


Use

ps.setString(1, "%" + o.getOrgan() + "%");

Note the absence of quotes.



来源:https://stackoverflow.com/questions/40192410/how-to-implement-like-operator-in-prepared-statement

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!