Can PreparedStatement.addBatch() be used for SELECT queries?

前端 未结 4 814
遇见更好的自我
遇见更好的自我 2020-12-05 14:07

Imagine that I have 100 SELECT queries that differ by one input. A PreparedStatement can be used for the value.

All the documentation I see on the Web is for batch

4条回答
  •  伪装坚强ぢ
    2020-12-05 15:07

    As pointed out in other answers the JDBC Batch Updates does not work for SELECT queries or is at least not meant to be used for that.

    Since the question however mentions DB2 as the RDBMS, I think it is worth pointing out here (albeit a bit late now...), that the official driver for this particular database actually does offer this feature using DB2PreparedStatement#executeDB2QueryBatch() (see documentation for details). I am not aware of any other JDBC driver with this feature.

提交回复
热议问题