首页 > 解决方案 > 如何在 QueryRunner 中传递数组准备语句参数

问题描述

我正在尝试在 QueryRunner 上运行此查询。 select name from some_table where id in (?)

我的代码是

// val ids: MutableList<Int>
...
...
val query = "SELECT name FROM some_table WHERE id in (?);"
val result = QueryRunner().query(connection, query, ColumnListHandler<Int>(), ids.toIntArray())

我得到了这个错误,

java.sql.SQLException: Can't infer the SQL type to use for an instance of [I. Use setObject() with an explicit Types value to specify the type to use.

标签: sqlpostgresqlkotlin

解决方案


推荐阅读