Java 将clojure vec传递给语句(?)中的POSTGRES
我试图将一个字符串数组传递给select语句,但一直出现错误:Java 将clojure vec传递给语句(?)中的POSTGRES,java,sql,postgresql,clojure,interop,Java,Sql,Postgresql,Clojure,Interop,我试图将一个字符串数组传递给select语句,但一直出现错误: org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of clojure.lang.PersistentVector. Use setObject() with an explicit Types value to specify the type to use. 我知道列类型是正确的,看起来传递向量就是罪魁祸首。正
org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of clojure.lang.PersistentVector. Use setObject() with an explicit Types value to specify the type to use.
我知道列类型是正确的,看起来传递向量就是罪魁祸首。正确的方法是什么
sql语句的格式如下:
“从(?)中的项目id所在的表中选择*”这个答案假设您使用的是jdbc,而不是korma或类似的东西,并且需要直接生成sql,而不是通过某种工具: 指令中的
要求您为列表中的每个项目装箱一个?
。当其他事情需要我手动构建SQL时,我最终使用此模式:
(let [placeholders (s/join ", " (repeat (count things-go-here) "?"))
query "SELECT * FROM said_table WHERE item_id IN (%s)"]
(exec-raw [(format query placeholders) things-go-here] :results)
....)
可能会显示您的代码