[英]Reliablility of Statement.getGeneratedKeys()
I found that Statement.getGeneratedKeys()
can be used for retrieving the ids of the inserted rows. 我发现
Statement.getGeneratedKeys()
可用于检索插入的行的ID。 But I wanted to know is it reliable, if we have multiple JDBC connections performing insert operation simultaneously. 但是我想知道,如果我们有多个JDBC连接同时执行插入操作,它是否可靠。
From Docs of getGeneratedKeys()
来自
getGeneratedKeys()
文档
Retrieves any auto-generated keys created as a result of executing this Statement object.
检索由于执行此Statement对象而创建的任何自动生成的键。
When you create a Statement from a Connection Object, the generated keys are belongs to that particular statement. 从连接对象创建语句时,生成的键属于该特定语句。 And they return the specific id's inserted.
并且它们返回插入的特定ID。 So you'll safely get those.
这样您就可以安全地获得这些。
除非您正确使用JDBC,否则工作正常,直到很长时间为止。我使用getGeneratedKeys()已有很长时间,并且直到现在都没有遇到任何问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.