Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


Can we use the one instance of Statment to execute more
than one query ?

Answers were Sorted based on User's Feedback



Can we use the one instance of Statment to execute more than one query ?..

Answer / sathya


Yes,its possible to use the same instance provided the
Result Set of the first Statement is fetchd out.

Is This Answer Correct ?    4 Yes 0 No

Can we use the one instance of Statment to execute more than one query ?..

Answer / 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

More JDBC Interview Questions

How many categories of jdbc drivers are there?

0 Answers  


Explain about Join?

0 Answers  


What are JDBC statements?

2 Answers  


Does jpa use jdbc?

0 Answers  


DB2 Universal claims to support JDBC 2.0, But I can only get JDBC 1.0 functionality. What can I do?

0 Answers  






What do you understand by DDL and DML statements?

0 Answers  


How do you debug PL/SQL code?

1 Answers  


Is jdbc an api?

0 Answers  


Is JDBC a language or Application?

3 Answers  


Is java a database?

0 Answers  


what happen if we set JDBC string to NULL?

0 Answers   Sapient,


What is Type-1 Driver and when this driver is used?

3 Answers  






Categories