Can we use the one instance of Statment to execute more
than one query ?
Answers were Sorted based on User's Feedback
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 |
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 |
What do you understand by jdbc driver and explain its types?
What is the use of jdbc?
Why do we need a jdbcrowset like wrapper around resultset?
How do I know which jdbc driver to use?
Explain the various types of locking system in jdbc?
What are the jdbc statements?
Where can I find ojdbc14 jar file?
What is the difference between execute, executeQuery, executeUpdate?
What is executeupdate in java?
How can I instantiate and load a new CachedRowSet object from a non-JDBC source?
How can I use the JDBC API to access a desktop database like Microsoft Access over the network?
What is the equivalent method for precompiled SQL Statement in JDBC?