PreparedStatement IN clause alternatives?

前端 未结 30 4498
情歌与酒
情歌与酒 2020-11-21 05:19

What are the best workarounds for using a SQL IN clause with instances of java.sql.PreparedStatement, which is not supported for multiple values du

30条回答
  •  不要未来只要你来
    2020-11-21 05:43

    try using the instr function?

    select my_column from my_table where  instr(?, ','||search_column||',') > 0
    

    then

    ps.setString(1, ",A,B,C,"); 
    

    Admittedly this is a bit of a dirty hack, but it does reduce the opportunities for sql injection. Works in oracle anyway.

提交回复
热议问题