1Z0-805 · Question #62
Which two descriptions are benefits of using PreparedStatement objects over static SQL in JDBC?
The correct answer is A. Conversion to native SQL D. Improved performance from frequently run SQL queries. Sometimes it is more convenient to use a PreparedStatement object for sending SQL statements to the database. This special type of statement is derived from the more general class, Statement, that you already know. If you want to execute a Statement object many times, it…
Question
Which two descriptions are benefits of using PreparedStatement objects over static SQL in JDBC?
Options
- AConversion to native SQL
- BSupports BLOB types on every type of database
- CPrevention of SQL injection attacks
- DImproved performance from frequently run SQL queries
- EBuilt in support for multi database transaction semantics
How the community answered
(54 responses)- A81% (44)
- B2% (1)
- C6% (3)
- E11% (6)
Explanation
Sometimes it is more convenient to use a PreparedStatement object for sending SQL statements to the database. This special type of statement is derived from the more general class, Statement, that you already know. If you want to execute a Statement object many times, it usually reduces execution time to use a PreparedStatement object instead. The main feature of a PreparedStatement object is that, unlike a Statement object, it is given a SQL statement when it is created. The advantage to this is that in most cases, this SQL statement is sent to the DBMS right away, where it is compiled. As a result, the PreparedStatement object contains not just a SQL statement, but a 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. Although PreparedStatement objects can be used for SQL statements with no parameters, you probably use them most often for SQL statements that take parameters. The advantage of using SQL statements that take parameters is that you can use the same statement and supply it with different values each time you execute it.
Topics
Community Discussion
No community discussion yet for this question.