Hi my doubt is that preparedStatement is a interface means
which has no implemenation.plz go thru the code below
String sql = "SELECT * FROM movies WHERE year_made = ?";
prest = con.prepareStatement(sql);
prest.setInt(1,2002);
ResultSet rs1 = prest.executeQuery();

Now setInt and executeQuery how it works since it is
interface it does not have implementation how it works, how
executeQuery returns result from database as executequery
method has no implementation even in Statement interface.

Answer Posted / kanu

Since the prepared statement is a precompiled statement and
this SQL statement is sent to the DBMS right away, where it
is compiled. As a result, the PreparedStatement object
contains not just an SQL statement, but an SQL statement
that has been precompiled. This means that when the
PreparedStatement is executed, the DBMS can just run the
PreparedStatement SQL statement without having to compile
it first.

Is This Answer Correct ?    4 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the difference between resultset and rowset in jdbc

529


What are the benefits of PreparedStatement over Statement?

522


What is jdbc connection string?

503


What is connection pooling and why it is used?

520


What is jdbc driver for sql server?

530






Is jdbc part of j2ee?

507


What is meant by connection string?

549


Discuss the procedure of retrieving warnings?

551


What is a jdbc url?

457


How can I use the JDBC API to access a desktop database like Microsoft Access over the network?

525


How can you load the drivers?

546


Why is jdbc used?

516


What is a jdbc connection?

466


What are dml and ddl?

532


What is the use of getGeneratedKeys() method in Statement?

527