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 does a file store compare with a jdbc store?

0 Answers  


Can I use JDBC to execute non-standard features that my DBMS provides?

0 Answers  


Are there any ODBC drivers that do not work with the JDBC- ODBC Bridge?

2 Answers  


What are restrictions on triggers?

0 Answers  


What causes the "No suitable driver" error?

0 Answers  






How can you tune SQL statements?

2 Answers   Wipro,


Write a program JDBCcode forfetching student database with SQL.

0 Answers  


Give an example of code used for setting up connection with a driver.

0 Answers  


why are using type4 driver in realtime projects?

4 Answers  


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

0 Answers  


How can I know when I reach the last record in a table, since JDBC doesn't provide an EOF method?

0 Answers  


Which package is used for jdbc application?

0 Answers  






Categories