Tag Archives: Diffrence between

JDBC: Difference between Statement, PreparedStatement and CallableSatement


JDBC API introduced statement, PreparedStatement and CallableStatemnet to execute different types of queries:

  1. Statement : Used to execute Normal SQL Queries.
  2. PreparedStatement: Used to execute dynamic or parameterized queries.
  3. CallableStatement: Used to execute StoredProcedure.

Statement Vs PreparedStatement Vs CallableStatement

Statement Prepared Statement Callable Statement
It is used to execute normal SQL queries. It is used to execute dynamic or parameterized SQL queries. It is used to execute Stored procedure or function.
It is proffered when particular query to be executed only once. It is proffered when particular query to be executed multiple times. It is proffered when stored procedure or functions to be executed.
You can no pass parameter to query by using this interface. You can pass parameter to query at run time by using this interface. You can pass three types of parameters by using this interface IN, OUT and IN OUT
This interface mainly used for DDL statements like CREATE, ALTER , DROP etc. This is used to be any kind of SQL queries which are used multiple times It is used with Stored Procedure and functions.
The performance of this interface is very low. The performance of this interface is better than query while using with multiple queries. Performance of this interface is very high because stored procedure execute on database end.
For More: Statement For More: Prepared Statement For More: Callable Interface

More on JDBC

Follow below links to know more on JDBC and solving JDBC issues :

Advertisements