Tuesday, June 20, 2017

Difference between excuteQuery(), excute(), exceteUpdate() in JDBC



excuteQuery(), excute(), exceteUpdate()::-


execute():- used to execute any SQL command

executeUpdate():- used to execute only non-select commans, like Insert,delete ,update

ececuteqQuery() :- used to execute select commands.

execteBatch():- used to executes set of non-select commands.

Call executeQuery() on JDBC statement obj to send and execute SQL select Query in DB s/w. This method returns result set Obj representing batch of records that are retrieved.

Call executeUpdate(-) on JDBC statement obj to send and execute SQL non-select query in DB s/w. This method returns numeric value representing no of records that are effected.


BatchProcessing/batchUpdation:-

          Inset of that keep all the related SQL Queries in a batch and send that batch to db s/w at once and execute that batch of SQL queries back to java apps as a batch. This is calle batch processing and it reduces s/w round trips b/w java applications and db s/w.

         We can place select SQL queries in batch of batch processing so it is called as a batch updation because all non-select SQL Queries are called as called as updateQuerys.

To add SQL Queries to batch use addBatch() and to execute batch of SQL queries use executeBatch(0 method.

No comments:

Post a Comment