Return to site

☕🎓JAVA CERTIFICATION QUESTION: PreparedStatement

· java,ocp

Among the following statements, identify the true statement:

* PreparedStatement helps prevent SQL injection attacks by precompiling the SQL query and allowing parameterized queries.

* PreparedStatement cannot execute batch updates; it is only designed for single SQL statements.

* PreparedStatement can only be used for SELECT queries and not for INSERT, UPDATE, or DELETE operations.

* PreparedStatement objects do not support setting parameters dynamically at runtime.

#java #certificationquestion #ocp

https://www.udemy.com/course/ocp-oracle-certified-professional-java-developer-prep/?referralCode=54114F9AD41F127CB99A

True: PreparedStatement helps prevent SQL injection attacks by precompiling the SQL query and allowing parameterized queries.

Incorrect Statements:

False: PreparedStatement cannot execute batch updates; it is only designed for single SQL statements.

Correction: PreparedStatement can execute batch updates using the addBatch() and executeBatch() methods.

False: PreparedStatement can only be used for SELECT queries and not for INSERT, UPDATE, or DELETE operations.

Correction: PreparedStatement can be used for various types of SQL operations, including SELECT, INSERT, UPDATE, and DELETE.

False: PreparedStatement objects do not support setting parameters dynamically at runtime.

Correction: PreparedStatement objects allow setting parameters dynamically using methods like setInt(), setString(), setDate(), etc., which enable dynamic query construction.