Can we use the one instance of Statment to execute more
than one query ?
Answer Posted / sachin
To make batch updates using a single statement with several
sets of input parameters, follow these basic steps:
Disable AutoCommit for the Connection object.
Invoke the prepareStatement method to create a
PreparedStatement object for the SQL statement with input
parameters.
For each set of input parameter values:
Execute setXXX methods to assign values to the input
parameters.
Invoke the addBatch method to add the set of input
parameters to the batch.
Invoke the executeBatch method to execute the statements
with all sets of parameters.
Check for errors. If no errors occurred:
Get the number of rows that were updated by each execution
of the SQL statement from the array that the executeBatch
invocation returns.
Invoke the commit method to commit the changes.
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What are clob and blob data types in jdbc?
What are the conditions applies to varchar variable, when using in procedures?
java based application for hospital management
What is the significance of DataBaseMetaData.tableIndexStatistics? How to obtain and use it?
How can I determine where a given table is referenced via foreign keys?
What is meant by jdbc?
What is an odbc driver?
I have the choice of manipulating database data using a byte[] or a java.sql.blob. Which has best performance?
Where is mysql jdbc driver located?
What are the types of jdbc drivers that exist?
What are the common jdbc exceptions?
What is correlated subquery?
When does the result for an sql statement return null?
Is not bound in this context unable to find jdbc spring boot?
What is executequery in java?