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


Please Help Members By Posting Answers For Below Questions

How do I find ojdbc jar version?

694


How can we store the file in the oracle database?

728


What is jdbc odbc bridge in java?

782


What happens if we don't close the connection in jdbc?

657


What are the benefits of PreparedStatement over Statement?

777


Explain Basic Steps in Writing a Java Program Using Jdbc?

816


What is JDBC Transaction Management and why do we need it?

752


Which is best database for java?

745


What is resultset in jdbc with example?

698


How does jdbc work?

683


What are the different types of interfaces in the api component?

741


Write an sql to find all records having all upper case alphanumeric characters in a field ?

732


What is difference between jdbc and odbc?

712


What are collection pools?

733


What is jdbc odbc connection?

727