java - statement.getGeneratedKeys() and MySQL -


i've learned hard way last_insert_id in mysql not pool-safe. i.e. if pooling connections, you'll messed insert_ids. how java's statement.getgeneratedkeys() key on inserts? pool-safe?

i quoting relevant text mysql connector/j internals here:

you should aware, @ times, can tricky use 'select last_insert_id()' query, function's value scoped connection. so, if other query happens on same connection, value overwritten. on other hand, 'getgeneratedkeys()' method scoped statement instance, can used if other queries happen on same connection, not on same statement instance.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -