加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

java-statement.getGeneratedKeys()和MySQL

发布时间:2020-12-11 23:26:22 所属栏目:MySql教程 来源:网络整理
导读:我已经学会了很难在mysql中last_insert_id不是池安全的.即,如果您正在池化连接,则会搞砸insert_ids. java的statement.getGeneratedKeys()如何获取插入的键?游泳池安全吗?最佳答案我在这里引用了MySQL Connector / J internals的相关文本: You should be a

我已经学会了很难在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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读