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

Explain about multiple implementations and drive manager?

0 Answers  


Why do we need jdbc driver?

0 Answers  


What is JDBC Connection? Explain steps to get Database connection in a simple java program.

0 Answers  


There is a method getColumnCount in the JDBC API. Is there a similar method to find the number of rows in a result set?

0 Answers  


What is statement and resultset in jdbc?

0 Answers  






What is jdbc connection interface?

0 Answers  


what is CallableStatement and what is its usage?

1 Answers  


What is the full form of jdbc?

0 Answers  


What is the meaning of batch updates?

0 Answers  


Explain the role of driver in jdbc.

0 Answers  


What is difference between statement and preparedstatement in jdbc?

0 Answers  


If you are truncated using JDBC, how can you that how much data is truncated?

0 Answers  


Categories