Return to site

🍃🎓 SPRING CERTIFICATION QUESTION: Which one is NOT a callback interface that works with JdbcTemplate?

· spring,vcp,java

Which one is NOT a callback interface that works with JdbcTemplate?

* ResultSetMapper

* RowCallbackHandler

* ResultSetExtractor

* RowMapper

#spring #certificationquestion #vcp

The correct answer to the question is:

`ResultSetMapper` is not a callback interface that works with `JdbcTemplate`.

While:

`ResultSetMapper`, `RowCallbackHandler`, `ResultSetExtractor`, and `RowMapper` are callback interfaces that work with `JdbcTemplate` in Spring Framework.

Here's a brief explanation of the other callback interfaces:

1. `RowCallbackHandler`: This interface is used to process each row of the result set returned by a query.

It is used when you want to perform some custom processing for each row but don't need to return a result object.

2. `ResultSetExtractor`: This interface is used to extract a result object from a ResultSet.

It is typically used when you want to return a single result object (e.g., a domain object) from a query.

Best choice when multiple rows of a ResultSet map to a single object.

3. `RowMapper`: This interface is used to map a row of the ResultSet to an object.

It's commonly used when you want to map each row of the result set to a separate object, such as when executing a query that returns a list of objects.

Best choice when each row of a ResultSet maps to a domain object.

These callback interfaces provide flexibility and control when working with the `JdbcTemplate` in Spring by allowing you to customize the processing of query results.