When you use normal statements compilation of statement or
parsing of statement will happen every time. This is time
consuming when u have multiple queries to execute.
Statement s = conn.createStatement();
In prepared statement SQL query will be compiled or parsed
for the very first time and kept in some kind of pool. When
u execute one more time the same statement with different
values it saves the parsing time.
The PreparedStatement is a slightly more powerful version of a Statement, and should always be at least as quick and easy to handle as a Statement.
The PreparedStatement may be parametrized.
Prepared statement is precompiled statement it is used when
we want one query to be executed n no. of times.
Prepared Statement is Pre-compiled class , but Statement is not.
So in PreparedStatement the execution will be faster.
SQL select * from employee where employeeID=?,empName=?;
PreparedStatement ps = conn.PreparedStatement();
Callable statements are used to execute stored procedures
similar to java functions.