CodesJava

Easy learning with example program codes

What is the difference between Statement and PreparedStatement in jdbc?


Statement PreparedStatement
  1. Statement not executes the parameterized query.
  2. Relational DB uses following 4 step to execute a query:
    a. Parse the query.
    b. Compile the query.
    c. Optimize/Plan the query.
    d. Execute the query.
    A statement always executes the all four steps.
  3. No database statement caching in case of statement.
  1. PreparedStatement can execute the parameterized query.
  2. Relational DB uses following 4 step to execute a query:
    a. Parse the query.
    b. Compile the query.
    c. Optimize/Plan the query.
    d. Execute the query.
    PreparedStatement pre-executes first three steps in the execution.
  3. It provides the database statement caching the execution plans of previously executed statements. Hence database engine can reuse the plans for statements that have been executed previously.

Related topics

Posted in JDBC   
Sign Up/ Sign In
Ask a Question


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki