Using the statement cache Compilationavoiding by using PreparedStatements Prepared statementsperformance benefits of Statement cacheperformance benefits of

The statement cache is enabled by default. You can use it to avoid extra compilation overhead:

supports the ParameterMetaData interface, new in JDBC 3.0. This interface describes the number, type, and properties of prepared statement parameters. See the for more information.

A connection need only compile a <i>PreparedStatement</i> onceSubsequent executions can use the same statement execution plan even if the parameter values are different. (PreparedStatements are not shared across connections.) Multiple executions of the same PreparedStatement and their relationship to the statement execution plan.

Remember that if your application executes statements that are almost but not exactly alike, it is more efficient to use PreparedStatements with dynamic or IN parameters. A database can reuse a statement execution plan when the SQL text matches a prior statement <i>exactly</i> (PreparedStatements are much more efficient.) The database reusing a statement execution plan that is already in the statement cache.