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

Without using of Class.forName(? ?), how do you connect to db?

3 Answers   IBM,


I have the choice of manipulating database data using a byte[] or a java.sql.blob. Which has best performance?

0 Answers  


What is phantom read and which isolation level prevents it?

0 Answers  


What is the fastest type of JDBC driver?

0 Answers  


How do I check in my code whether a maximum limit of database connections have been reached?

0 Answers  






JDBC Drivers properties?

1 Answers   Infosys,


How do I start debugging problems related to the JDBC API?

0 Answers  


Why did my jdbc code throw a rollback sqlexception?

0 Answers  


How many categories of jdbc drivers are there?

0 Answers  


What is ODBC and JDBC? How do you connect the Database?

0 Answers  


What is type 4 jdbc driver?

0 Answers  


Where is mysql jdbc driver located?

0 Answers  


Categories