2V0-72-22 practice question 1 of 15

Which two statements describe Spring JdbcTemplate? (Choose two.)

Full set: 79 questions
Answer options
A:

A. All JdbcTemplate methods throw SQLException which you are required to handle.

B:

B. The JdbcTemplate provides the ability to work with result sets.

Correct answer
C:

C. The JdbcTemplate can only perform update but not insert to the database.

D:

D. The JdbcTemplate provides methods for query execution.

Correct answer
E:

E. The JdbcTemplate generates SQL statements.

Correct Answer:
B. B. The JdbcTemplate provides the ability to work with result sets.; D. D. The JdbcTemplate provides methods for query execution.
Explanation

The Spring JdbcTemplate class is the central class in the JDBC core package. It simplifies the use of JDBC and helps to avoid common errors. It executes SQL queries, update statements, and stored procedure calls, performing iteration over ResultSets and extraction of returned parameter values. It also translates the checked SQLExceptions from the JDBC API into a hierarchy of unchecked DataAccessExceptions, relieving the developer from handling specific database vendor error codes.

Why Incorrect

A. JdbcTemplate translates checked SQLExceptions into a hierarchy of unchecked DataAccessExceptions, so you are not required to handle SQLException directly.
C. The update method in JdbcTemplate can be used for INSERT, UPDATE, and DELETE operations, not just updates.
E. JdbcTemplate executes SQL statements that you provide; it does not generate them. SQL generation is a feature of ORM frameworks like JPA.

References

1. Spring Framework Documentation. (Version 6.1.6). Data Access, Section 1.2.3, "JdbcTemplate". "The template provides methods for querying... and for performing updates...".

2. Spring Framework Documentation. (Version 6.1.6). Data Access, Section 1.2.1, "Choosing an Approach for JDBC Database Access". "The JdbcTemplate... converts the standard JDBC SQLExceptions into a hierarchy of generic, more informative, unchecked exceptions."

3. Spring Framework Documentation. (Version 6.1.6). API Reference, org.springframework.jdbc.core.JdbcTemplate. The class documentation lists methods like query(String sql, ResultSetExtractor rse) and update(String sql, @Nullable Object... args).

Scroll to Top