【发布时间】:2011-06-14 11:50:41
【问题描述】:
我想在自动生成键的表中插入很多行。 JDBC 不保证获取生成的密钥对批量更新有效。
It is implementation-defined as to whether getGeneratedKeys will return
generated values after invoking the executeBatch method.(JDBC 4.0 规范 2006,第 135 页)。
我有两个选择。分别插入每一行,得到key。或者批量插入,然后查询key。
为了避免查询多个键的往返,我可以使用这种方法here。有例如5个不同大小的准备好的语句。然后将我的“批量查询”分解成尽可能小的语句。
更快的方法是什么?
【问题讨论】:
标签: select jdbc insert prepared-statement batch-updates