|
INTERVIEW QUESTIONS
J2EE
JDBC
DETAILS
Question: What is the advantage of using a PreparedStatement?
Answer: For SQL statements that are executed repeatedly, using a PreparedStatement object would almost always be faster than using a Statement object. This is because creating a PreparedStatement object by explicitly giving the SQL statement causes the statement to be precompiled within the database immediately. Thus, when the PreparedStatement is later executed, the DBMS does not have to recompile the SQL statement and prepared an execution plan - it simply runs the statement. Typically, PreparedStatement objects are used for SQL statements that take parameters. However, they can also be used with repeatedly executed SQL statements that do not accept parameters.
|
|
|
Category |
JDBC Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.3) By 7492 users |
Added on |
9/12/2014 |
Views |
67939 |
Rate it! |
|
|
Question:
What is the advantage of using a PreparedStatement?
Answer:
For SQL statements that are executed repeatedly, using a PreparedStatement object would almost always be faster than using a Statement object. This is because creating a PreparedStatement object by explicitly giving the SQL statement causes the statement to be precompiled within the database immediately. Thus, when the PreparedStatement is later executed, the DBMS does not have to recompile the SQL statement and prepared an execution plan - it simply runs the statement. Typically, PreparedStatement objects are used for SQL statements that take parameters. However, they can also be used with repeatedly executed SQL statements that do not accept parameters. Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
How do I create a database connection?
|
View Answer
|
|
What is Metadata and why should I use it?
|
View Answer
|
|
How does the Java Database Connectivity (JDBC) work?
|
View Answer
|
|
How do I extract the SQL statements required to move all tables and views from an existing database to another database?
|
View Answer
|
|
What does ResultSet actually contain? Is it the actual data of the result or some links to databases? If it is the actual data then why can't we access it after connection is closed?
|
View Answer
|
|
Which is the preferred collection class to use for storing database result sets?
|
View Answer
|
|
How can I connect from an applet to a database on the server?
|
View Answer
|
|
How do I insert an image file (or other raw data) into a database?
|
View Answer
|
|
How can resultset records be restricted to certain rows?
|
View Answer
|
|
How can I connect to an Excel spreadsheet file using jdbc?
|
View Answer
|
|
How can I pool my database connections so I don't have to keep reconnecting to the database?
|
View Answer
|
|
What is the difference between client and server database cursors?
|
View Answer
|
|
How can I insert multiple rows into a database in a single transaction?
|
View Answer
|
|
How can I connect to an Oracle database not on the web server from an untrusted applet?
|
View Answer
|
|
How do I create an updatable ResultSet?
|
View Answer
|
|
How do I create an updatable ResultSet?
|
View Answer
|
|
How can I determine whether a Statement and its ResultSet will be closed on a commit or rollback?
|
View Answer
|
|
Is there a practical limit for the number of SQL statements that can be added to an instance of a Statement object
|
View Answer
|
|
What does setFetchSize() really do?
|
View Answer
|
|
What scalar functions can I expect to be supported by JDBC?
|
View Answer
|