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

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

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