mysql last_insert_id()是否可用于连接池? [英] Does mysql last_insert_id() work for connection pool?

查看:465
本文介绍了mysql last_insert_id()是否可用于连接池?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个bigint类型的自动递增列.调用mysql_insert_id()可以很好地获取先前为连接插入的ID.即使使用了tomcat容器中的连接池,它也能很好地工作(标识最后插入的id)吗?

I have a auto increment column of type bigint. Calling mysql_insert_id() works good for getting the previously inserted id for the connection. Does it work great(identifying the last inserted id) even if a connection pool in a tomcat container is used ?

推荐答案

不要使用像这样的数据库特定代码,它只会使代码的可移植性降低.在执行更新时,请使用Statement.RETURN_GENERATED_KEYS选项.

Don't use database specific code like that, it'll only make your code less portable. Instead use the Statement.RETURN_GENERATED_KEYS option when executing an update.

这是您搜索的开始: sql jdbc getgeneratekeys返回列"id".找不到,列类型未知

这篇关于mysql last_insert_id()是否可用于连接池?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆