What is PreparedStatement?

Answer Posted / guest

There's a popular belief that using a PreparedStatement
object is faster than using a Statement object. After all, a
prepared statement has to verify its metadata against the
database only once, while a statement has to do it every
time. So how could it be any other way? Well, the truth of
the matter is that it takes about 65 iterations of a
prepared statement before its total time for execution
catches up with a statement. This has performance
implications for your application, and exploring these
issues is what this section is all about.

When it comes to which SQL statement object performs better
under typical use, a Statement or a PreparedStatement, the
truth is that the Statement object yields the best
performance. When you consider how SQL statements are
typically used in an application--1 or 2 here, maybe 10-20
(rarely more) per transaction--you realize that a Statement
object will perform them in less time than a
PreparedStatement object. In the next two sections, we'll
look at this performance issue with respect to both the OCI
driver and the Thin driver.

Is This Answer Correct ?    0 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is two-phase commit in the database?

525


Is jdbc a middleware?

510


What do you mean by odbc?

551


What is an SQL Locator?

591


What is the meaning of batch updates?

566






What causes the "No suitable driver" error?

538


How do I insert/update records with some of the columns having NULL value?

514


What is an odbc driver?

489


What is a statement?

580


What is a java driver?

504


Once I have the Java 2 SDK, Standard Edition, from Sun, what else do I need to connect to a database?

546


What is meant by connection string?

558


What is jdbc resultsetmetadata interface?

536


List the advantages of using datasource?

559


What are the different types of locking in JDBC?

574