What is Statement and PreparedStatement? whatz the
difference?

Answers were Sorted based on User's Feedback



What is Statement and PreparedStatement? whatz the difference?..

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

What is Statement and PreparedStatement? whatz the difference?..

Answer / kalyan

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

Post New Answer

More JDBC Interview Questions

What is the difference between executing, executequery, executeupdate in jdbc?

0 Answers  


What are clob and blob data types in jdbc?

0 Answers  


how we can remove hard code in java?

1 Answers   Satyam,


How can you sort dates?

1 Answers  


What is ODBC and JDBC? How do you connect the Database?

0 Answers  






What is the full form of jdbc and what is its purpose?

0 Answers  


What is the latest version of JDBC? What new features are added?

4 Answers  


What is Type-4 Driver and when this driver is used?

3 Answers  


What do you mean by metadata and why we are using it?

0 Answers  


What is the most common example type 1 driver?

0 Answers   Tech Mahindra,


How many types of jdbc drivers are there?

0 Answers  


Why would you use setautocommit(false) in jdbc?

0 Answers  


Categories