Tuesday, May 22, 2007

What is PreparedStatement and how is different from Statement?

A PreparedStatement, in contrast to a Statement, is used for SQL statements that are executed multiple times with different values. For instance, you might want to insert several values into a table, one after another. The advantage of the PreparedStatement is that it is pre-compiled, reducing the overhead of parsing SQL statements on every execution.
In such cases DBMS will execute the query directly without worrying about compiling the statement again.


