[英]JDBC: How to pass List of object into preparedStatement, or for a better alternative
I have a question about JDBC. 我对JDBC有疑问。
PreparedStatement preparedStatement =
dbConnection.prepareStatement(
"SELECT userid, roleid, name from permission
where (userid, roleid) in (?)");
// assume I cannot update the above line, which is maintained by others
// now I just get a PreparedStatement and a list of object
Set<Pair<Integer, Integer>> idPair = ....
How can I execute the query with idPair
variable? 如何使用idPair
变量执行查询?
PS: ( userid
, roleid
) together are primary key for permission
table PS:( userid
, roleid
)一起是permission
表的主键
Thank you so much! 非常感谢!
You can not. 你不能。
You need to resort to plain SQL with iteration and filtering. 您需要通过迭代和过滤求助于普通SQL。
This is not JDBC specific, but AFAIK universal to most drivers. 这不是JDBC特定的,而是大多数驱动程序通用的AFAIK。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.