What is Statement and PreparedStatement? whatz the
difference?
Answers were Sorted based on User's Feedback
Answer / harish
When you execute a SQL query with Statement. It parses and
executes in the database each time. Where as in
PreparedStatement, first time it parses and executes and
subsequent times, it directly substitute the values in the
query and executes. It is faster than Statement
| Is This Answer Correct ? | 11 Yes | 2 No |
As harish, said prepared statement is pre-complied so it
will be very fast when compared to normal statement.when we
execute same query again and again for different set of
input data.
code snippet for this is :--
for normal statement :
Statement st = conn.createStatement();
for prepared statement :
PreparedStatement prSt = conn.prepareStatement
("query") ;
// set values for input paramenters and execute as usual.
| Is This Answer Correct ? | 2 Yes | 2 No |
What class.forname does, while loading the drivers?
What is JDBC Statement?
What is meant by connection string?
Which Java and java.sql data types map to my specific database types?
Is there another way of dealing with the result set that could execute faster?
How does jdbc connect to database?
What is the meaning of “dirty read” in the database?
How do I set properties for a JDBC driver and where are the properties stored?
What is the return type of execute, executequery and executeupdate?
What is the difference between Union, Unionall ?
What are the differences between execute, executequery, and executeupdate?
Why do we need jdbc api?