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 are the advantages of database connection pooling?

0 Answers  


List the common jdbc exceptions ?

0 Answers  


How to update a resultset programmatically?

0 Answers  


What is database connection pooling? Advantages of using a connection pool?

0 Answers  


Is jdbc an api?

0 Answers  






write a query to select name from one table which has id,name and salary from another table which has id, sal where the salary is the second maximum

3 Answers   Bosch, HireCraft, Infosys,


Explain some new features available in jdbc 4.0?

0 Answers  


How many types of statements are there in jdbc?

0 Answers  


Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection?

0 Answers  


What are the common jdbc exceptions?

0 Answers  


Can I get a null resultset?

0 Answers  


how can connection with oracle10g with java

3 Answers   IonIdea,


Categories