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 can I instantiate and load a new CachedRowSet object from a non-JDBC source?

725


What port does jdbc use?

711


What is meant by jdbc?

682


What is drivermanager in jdbc?

723


What are the factors that the jdbc driver performance depends upon?

716


How to use JDBC API to call Stored Procedures?

746


What is jdbc driver manager?

685


How can you retrieve data from the resultset using jdbc?

739


Is jdbc object oriented?

689


Why can't I invoke the ResultSet methods afterLast and beforeFirst when the method next works?

890


What are the standard isolation levels defined by JDBC?

747


What are the different types of locking in JDBC?

757


What is an encrypted internet connection?

687


Explain creation of statement object with connection method create method with help of an example.

727


How many types of jdbc drivers are there?

740