skip to main content
Developing JDBC Applications : Fine-Tuning JDBC Application Performance : Retrieving Data : Using the Statement Object instead of the PreparedStatement Object
 

Using the Statement Object instead of the PreparedStatement Object

JDBC drivers are optimized based on the perceived use of the functions that are being executed. Choose between the PreparedStatement object and the Statement object depending on the planned use. The Statement object is optimized for a single execution of a SQL statement. In contrast, the PreparedStatement object is optimized for SQL statements that will be executed two or more times.
The overhead for the initial execution of a PreparedStatement object is high. The advantage comes with subsequent executions of the SQL statement.