What is the advantage of using a PreparedStatement?
Created May 4, 2012
Govind Seshadri For SQL statements that are executed repeatedly, using a PreparedStatement object would
almost always be faster than using a Statement object. This is because creating a
PreparedStatement object by explicitly giving the SQL statement causes the statement to be
precompiled within the database immediately. Thus, when the PreparedStatement is later
executed, the DBMS does not have to recompile the SQL statement and prepared an
execution plan - it simply runs the statement.
Typically, PreparedStatement objects are used for SQL statements that take parameters. However, they can also be used with repeatedly executed SQL statements that do not accept parameters.