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 is the JDBC?
What is meant by jdbc?
How can we set null value in jdbc preparedstatement?
What is the difference between jdbc and jndi?
What is executeupdate in java?
What is jdbc template?
What is JDBC Savepoint? How to use it?
password, is stored in as plain text. What can I do to protect my passwords?
Where is mysql jdbc driver located?
Why do we use jdbc?
DB2 Universal claims to support JDBC 2.0, But I can only get JDBC 1.0 functionality. What can I do?
What is metadata in programming?
There is a method getColumnCount in the JDBC API. Is there a similar method to find the number of rows in a result set?
What is the execute method in java?
How do I load a database driver with JDBC 4.0 / Java 6?