简体   繁体   中英

Reliablility of Statement.getGeneratedKeys()

I found that Statement.getGeneratedKeys() can be used for retrieving the ids of the inserted rows. But I wanted to know is it reliable, if we have multiple JDBC connections performing insert operation simultaneously.

From Docs of getGeneratedKeys()

Retrieves any auto-generated keys created as a result of executing this Statement object.

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. So you'll safely get those.

除非您正确使用JDBC,否则工作正常,直到很长时间为止。我使用getGeneratedKeys()已有很长时间,并且直到现在都没有遇到任何问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM