Reason being simple and not suppressing....
1:)Performance
2:)Efficiency
Actually when we get the statement object from connection object in JDBC there are three things that are done on DB side "FOR EVERY RUN OF THE JAVA PROGRAM"...
#1:The database query is first compiled
#2:there is a query plan that is generated by the database manager
#3:than at last we have the query being executed...
Now if we consider the case of the preparedStatement,than at the first run or execution of the program there is all the three steps that are carried out..but for the subsequent running of the program there will only be the last step that is carried out...
That's because the compiled query and the execution plan is already there with the DB...
Well than whats the use of having the statement object????
the prepapredStatement is considered to the static object...as there is only one type of query that you can possible execute with it....
Whereas in case of the statement object it considered to be the dynamic object as you can execute multiple query from one statement object.....
No comments:
Post a Comment