When using JdbcTemplate also we need to extend the JdbcDaoSupport in order to get the jdbc template by calling getJdbcTemplate() instead of wiring it in DAO.
My first question is going to be why? JdbcTemplate is
thread safe. I prefer to initialize it once in my Spring configuration and provide it where needed. Another approach you see sometimes is this
but once again I don't see the use of passing in the datasource. I just initialize the JdbcTemplate once in configuration and re-use it for all my DAO's like shown in the first example.
Now as to your other question.
Why do you
need to extend JdbcDaoSupport? If there is a need fine but otherwise I feel you are extending a framework class and needlessly coupling your application to the framework. In that case I prefer to use the approach above.
JdbcDaoSupport is a wrapper class. It wraps the JdbcTemplate class. So yes you can simply inject the datasource into the dao in this case the JdbcTemplate will be initialized automatically.
for example: