简体   繁体   English

mysql last_insert_id()是否适用于连接池?

[英]Does mysql last_insert_id() work for connection pool?

I have a auto increment column of type bigint. 我有一个bigint类型的自动增量列。 Calling mysql_insert_id() works good for getting the previously inserted id for the connection. 调用mysql_insert_id()非常适合获取先前插入的连接ID。 Does it work great(identifying the last inserted id) even if a connection pool in a tomcat container is used ? 即使使用tomcat容器中的连接池,它是否也能很好地工作(识别最后插入的id)?

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. 而是在执行更新时使用Statement.RETURN_GENERATED_KEYS选项。

Here's a start to your searches: sql jdbc getgeneratedkeys returns column "id" not found, column type unknown 这是搜索的开始: sql jdbc getgeneratedkeys返回未找到列“id”,列类型未知

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM