What is the advantage of using a PreparedStatement?
Location: http://www.jguru.com/faq/view.jsp?EID=720 Created: Nov 8, 1999 Modified: 2000-01-12 17:24:10.873 Author: Govind Seshadri (http://www.jguru.com/guru/viewbio.jsp?EID=14) 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.