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

前端 未结 4 818
遇见更好的自我
遇见更好的自我 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 14:58

    See the Java Tutorial:

    This list may contain statements for updating, inserting, or deleting a row; and it may also contain DDL statements such as CREATE TABLE and DROP TABLE. It cannot, however, contain a statement that would produce a ResultSet object, such as a SELECT statement. In other words, the list can contain only statements that produce an update count.

    The list, which is associated with a Statement object at its creation, is initially empty. You can add SQL commands to this list with the method addBatch.

提交回复
热议问题