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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by mnemonics?

515


What is the purpose of javac exe?

546


What is the static import?

573


Define how does a try statement determine which catch clause should be used to handle an exception?

566


What is string data type?

539






How do you use find and replace?

496


What is rule of accessibility in java?

533


Hi.... I applied for the post of scientific officer/Engineer-SB(Programmer).Please post the syllabus and sample papers.

1495


What is Mutex (Mutual Exclusion Object) ?

611


What is foreach loop in java?

513


what is the difference between the methods sleep() and wait()? : Java thread

496


What is the use of System class?

594


What is merge sort in java?

568


What is run time allocation?

564


What is difference between static variable and global variable?

537