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.

相关文章

在正式开始之前,我们先来看下 MySQL 服务器的配置和版本号信...
> [合辑地址:MySQL全面瓦解](https://www.cnblogs.c...
物理服务机的CPU、内存、存储设备、连接数等资源有限,某个时...
1 回顾 上一节我们详细讲解了如何对数据库进行分区操作,包括...
navicat查看某个表的所有字段的详细信息 navicat设计表只能一...
文章浏览阅读4.3k次。转载请把头部出处链接和尾部二维码一起...