Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What is a jdbc connection pool?

932


What is the role of jdbc drivermanager class?

1079


What are the main steps in java to make JDBC connectivity?

1007


What does executeupdate return in java?

1022


What does executeupdate return in jdbc?

970


What port does jdbc use?

966


How do I set properties for a JDBC driver and where are the properties stored?

964


How data can be inserted into long row column of database?

2143


How to set NULL values in JDBC PreparedStatement?

976


Which Java and java.sql data types map to my specific database types?

1062


Where is mysql jdbc driver located?

1028


What is odbc and jdbc in dbms?

953


Prepared statements are faster. Why?

1047


How do you determine the sensitivity of the ResultSet object?

982


Which interface handles transaction management in jdbc?

1104