BASIS OF COMPARISON | STATEMENT | PREPAREDSTATEMENT |
Description | This JDBC API interface is used for static SQL statements at run time. | The PreparedStatement interface is used for dynamic SQL statements at run time. |
Protocol | There is no specific protocol in statement interface. | The PreparedStatement used the non-SQL binary protocol. |
Accepting Parameters | The statement interface does not allow accepting parameters at runtime. | The PreparedStatement interface allow accepting parameters at runtime. |
Use | This interface is used when the SQL query is required to be executed only once. | This interface is used when the SQL query is required to be executed multiple times. |
Performance | The performance of the statement interface is comparatively not up to the mark. | The performance of the PreparedStatement interface is better than Statement. |
SQL Injection | The Statement interface enforces SQL injection. | The PreparedStatement does not enforce SQL injection. |
Function | The Statement interface does not extend the PreparedStatement interface. | The PreparedStatement interface extends the Statement Interface. |
Writing Concatenated SQL | There could be a possibility of writing concatenated SQL statements while using the Statement interface. | There’s no need of writing concatenated SQL statements when using the PreparedStatement interface. |
Execution | The SQL queries that are executed using Statement interface are executed at runtime and therefore, it is a little slower performance wise. | The SQL queries executed queries using PreparedStatement are pre-compiled and therefore, it offers a better performance. |
Data Retrieval | The statement interface cannot be used for retrieving or storing image and files in the databases. | The statement interface cannot be used for retrieving or storing image and files in the databases. |
Offer Method | This interface does not offer using setArray method in Java. | This interface offers using setArray method in Java. |
Commands | The commands that are mostly used in this interface are create, drop, truncate and alter. | The commands that are mostly used in this interface are select, delete, update and insert. |
Application | The statement interface is beneficial when using Data Definition Language (DDL) commands. | The PreparedStatement interface is beneficial when using Data Manipulation Language (DML) commands. |