sql - 如何在 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.
解决方案
推荐阅读
- amazon-web-services - 删除 AWS SNS 中的冗余终端节点和订阅
- mysql - 将表 A 多次连接到表 B
- apache-flink - 我可以通过状态处理器 api 读取 TumblingEventTimeWindows 中的状态吗?
- html - 如何使用 CSS 缩放两个图像?
- typescript - TypeScript 可以通过事件识别自定义类型吗?
- python - 安装成功后IfxPy模块导入错误
- swift - Promises + Alamofire 确保网络呼叫始终在后台
- c++ - 局部变量的范围是块或函数
- android - 在哪里存储 ReactNative + webview 应用程序的令牌?
- javascript - 如何从 SAPUI5 控制器向 Java Servlet 发出 POST 请求?