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 meaning of batch updates?

0 Answers  


Hi........I need to create a dropdown box using java.....this box should show the values that should be taken from the database...... Thank you....

1 Answers  


How to find the column count in resultset?

1 Answers   Wipro,


If I use the JDBC API, do I have to use ODBC underneath?

0 Answers  


What are the benefits of PreparedStatement over Statement?

0 Answers  






Explain the locking system in jdbc & its types?

0 Answers  


How many types of jdbc drivers are available?

0 Answers  


How do I find ojdbc jar version?

0 Answers  


Is java a database?

0 Answers  


How can you sort dates?

1 Answers  


Which jdbc driver type s is are the jdbc odbc bridge?

0 Answers  


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

0 Answers  


Categories