java-statement.getGeneratedKeys()和MySQL

前端之家收集整理的这篇文章主要介绍了java-statement.getGeneratedKeys()和MySQL 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我已经学会了很难在mysql中last_insert_id不是池安全的.即,如果您正在池化连接,则会搞砸insert_ids.
java的statement.getGeneratedKeys()如何获取插入的键?游泳池安全吗?

最佳答案
我在这里引用了MySQL Connector / J internals的相关文本:

You should be aware,that at times,it
can be tricky to use the ‘SELECT
LAST_INSERT_ID()’ query,as that
function’s value is scoped to a
connection. So,if some other query
happens on the same connection,the
value will be overwritten. On the
other hand,the ‘getGeneratedKeys()’
method is scoped by the Statement
instance,so it can be used even if
other queries happen on the same
connection,but not on the same
Statement instance.

原文链接:https://www.f2er.com/mysql/532178.html

猜你在找的MySQL相关文章