Vertx JDBC client queryWithParams - how to add a list?

前端 未结 2 1284
死守一世寂寞
死守一世寂寞 2021-01-22 14:14

I have SQL query with condition currency in ? and I\'m using vertx JDBC client queryWithparams method, which receives query parameters in JsonArray.

2条回答
  •  花落未央
    2021-01-22 14:53

    There are two options.

    If you want to support multiple databases, you'll have to expand your expression yourself:

    "... currency IN (" + String.join(",", Collections.nCopies(currencies.size(), "?")) + ")"
    

    If you support only PostreSQL, you can use ANY operator instead:

    WHERE currency = ANY(?)
    

提交回复
热议问题