Saturday, August 17, 2013

Difference between Statement and PreparedStatement

Statement
1. This interface is used for executing static
queries.
2. When we execute static queries with
respect to Statement object;
compilation, parsing and execution of
the query takes place each and every
time.
3. There is a possibility of loosing
performance of a jdbc program. Since,
compilation, parsing and execution
taking place each and every time.
.
PreparedStatement
1. This interface is used for executing
dynamic queries.
2. When we execute dynamic queries using
PreparedStatement object; compilation,
parsing and execution of the query takes
place first time and from second time
onwards only execution phase takes
place.
3. We can get the performance of jdbc
program. Since, compilation and parsing

takes place only one time