What is actual difference between statement,prepared
statement and callable statement and when we have to use it?
pls post a answer with code and clear explanation. thanks

Answers were Sorted based on User's Feedback



What is actual difference between statement,prepared statement and callable statement and when we h..

Answer / aravind

Statement:
When you use normal statements compilation of statement or
parsing of statement will happen everytime. This is time
cosuming when u have mutliple queries to execute.

Statemtn s = conn.createStatement();
s.executeQuery();

Prepared Statement:
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.

SQL select * from employee where employeeID=?,empName=?;
PreparedStatement ps = conn.PreparedStatement();
ps.execute(1,aru);
ps.execute(2,arya);

Callable Statement:

Callable statements are used to execute stored procedures
similar to java functions.

Is This Answer Correct ?    44 Yes 5 No

What is actual difference between statement,prepared statement and callable statement and when we h..

Answer / sudha

Prepared statement is precompiled statement it is used when
we want one query to be executed n no. of times.
whereas callablestatement is used to call stored procedures

Is This Answer Correct ?    41 Yes 3 No

Post New Answer

More Core Java Interview Questions

If we allocate the memory using 'new' & de-allocated using 'free' then what will happen?

0 Answers   CDAC,


Can a static method be overridden in java?

0 Answers  


What one should take care of, while serializing the object?

0 Answers  


Define how destructors are defined in java?

0 Answers  


What is the use of arrays tostring () in java?

0 Answers  






Which class is extended by all other classes?

4 Answers  


Is it necessary for the port addresses to be unique? Explain with reason.

0 Answers   Aricent,


How do you add an arraylist to an array in java?

0 Answers  


What are the differences between throw and throws?

0 Answers  


Why is string builder not thread safe?

0 Answers  


Java.util.regex consists of which classes?

0 Answers  


Compare Mutex and Semaphore in java.

0 Answers   Ciena,


Categories