将 Java Set 转换为PreparedStatement setString 方法的参数
将 Set
转换为 Oracle in (?)
的参数的最简单方法是什么?我已经为此使用了PreparedStatement。
What would be the simplest way to covert a Set<String>
to an argument for Oracle in (?)
? I am already using PreparedStatement for that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不能。查询必须为集合中的每个元素提供一个占位符 (
?
)。并且您必须绑定集合中的每个元素:如果您的集合包含三个元素,则准备好的语句必须如下所示:
并且您必须迭代集合并单独绑定每个元素:
You can't. The query must have one placeholder (
?
) for each of the elements in the set. And you have to bind every element of the set:If your set has three elements, your prepared statement must look like this :
and you must iterate through the set and bind each element individually: