1
我正在爲項目使用JDBI/Dropwizard,並且想要運行一些簡單的查詢。我有一個查詢,像這樣:在JDBI中使用IN子句中的字符串列表
private static final String GET_STUFF = "SELECT * FROM myTable WHERE state IN (:desiredState)"
我的變量綁定在我的方法,像這樣:
但是,在運行時,我得到了以下錯誤:
org.skife.jdbi.v2.exceptions.UnableToCreateStatementException:
Exception while binding 'desiredState'....
Caused by: org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of java.util.ArrayList. Use setObject() with an explicit Types value to specify the type to use.
我通過states
作爲String類型的ArrayList
,所以我有點困惑這裏發生了什麼。有沒有人知道用JDBI做In
的正確方法?
可能重複[Jdbi - 如何綁定列表參數在Java?](http://stackoverflow.com/questions/32526233/jdbi-how-to-bind-a -list-parameter-in-java) – pozs