JDBC Statement vs PreparedStatement vs CallableStatement

JDBC Statement, PreparedStatement and CallableStatement are interfaces which provide ways to interact with Databases(Oracle / MySQL / PostGre…etc) with the help of methods in it. But these statements have some difference in terms of features they provide.

JDBC Statement

Used for firing static queries(e.g. select * from table). JDBC Statements can not accept parameters.

Syntax of Statement

 

Prepared Statement

PreparedStatement extends Statement Interface to provide extra feature. It(PreparedStatement) is useful when firing the same SQL statement is required. PreparedStatement Interface accepts input parameter at runtime. PreparedStatement Objects are percompiled hence there execution is faster.

Syntax of PreparedStatement

 

 

CallableStatement

CallableStatement extends PreparedStatement Interface to provide more feature then PreparedStatement. It is used when database Stored Procedure needs to be invoked.

5 Comments JDBC Statement vs PreparedStatement vs CallableStatement

  1. Manish joshi

    not that much great but good content
    but it should be specify with some diagram and internal things then it will more helpfulL for beginner

    Reply

Leave A Comment

Your email address will not be published. Required fields are marked *