What statements are correct about batched insert and updates? (2 answers)

  1. [_] [a] To create a batch of insert and update statements, you create an object of type Batch,

  2. [_] [b] Batch insert and updates are only possible when making use of parameterized queries.

  3. [_] [c] To do a batched update/insert, you call addBatch(String statement) on a Statement

  4. [_] [d] To execute a batched update/insert, you call the executeBatch() method on a Statement


Correct Option: C,D

AI Explanation

To answer this question, let's go through each statement:

A) To create a batch of insert and update statements, you create an object of type Batch. This statement is incorrect. In general, to create a batch of insert and update statements, you would typically use an object of type PreparedStatement or CallableStatement, not Batch.

B) Batch insert and updates are only possible when making use of parameterized queries. This statement is not provided as an option, so it is not relevant to the question.

C) To do a batched update/insert, you call addBatch(String statement) on a Statement. This statement is correct. To add a SQL statement to a batch, you would call the addBatch(String statement) method on a Statement object. The statement parameter should be a valid SQL statement.

D) To execute a batched update/insert, you call the executeBatch() method on a Statement. This statement is correct. To execute a batch of SQL statements, you would call the executeBatch() method on a Statement object. This method returns an array of integers representing the update counts for each statement in the batch.

Based on the explanations above, the correct statements are C) and D).

Find more quizzes: