colin_young
Mar 27th, 2006, 09:16 PM
I'm attempting to follow the instructions in "Spring In Action" for jdbc data access, and I'm a bit confused about the proper way to do it. The book defines the class like this:
public class Deals implements JdbcDAO
{
private JdbcTemplate jdbcTemplate;
public void setJdbcTemplate(JdbcTemplate jdbcTemplate)
{
this.jdbcTemplate = jdbcTemplate;
}
But the downloaded code derives from JdbcDaoSupport (which provides a setter for jdbcTemplate). In any case, neither version works. The first version causes a null pointer exception when I try to access the jdbcTemplate methods (e.g. execute, query, etc.) and the second version doesn't do anything as far as I can tell (if I could get logging to work I might have more info -- I have another post about that problem).
It appears almost as if Spring is not wiring things up properly if I don't extend the JdbcDaoSupport class. Ideally, I'd like to be able to set 2 data sources, so I'd really like to be able to use provide 2 setters.
Is there a good document somewhere that can get me going? Not that SIA isn't good, but I'm obviously missing something.
Thanks for any pointers.
Colin
public class Deals implements JdbcDAO
{
private JdbcTemplate jdbcTemplate;
public void setJdbcTemplate(JdbcTemplate jdbcTemplate)
{
this.jdbcTemplate = jdbcTemplate;
}
But the downloaded code derives from JdbcDaoSupport (which provides a setter for jdbcTemplate). In any case, neither version works. The first version causes a null pointer exception when I try to access the jdbcTemplate methods (e.g. execute, query, etc.) and the second version doesn't do anything as far as I can tell (if I could get logging to work I might have more info -- I have another post about that problem).
It appears almost as if Spring is not wiring things up properly if I don't extend the JdbcDaoSupport class. Ideally, I'd like to be able to set 2 data sources, so I'd really like to be able to use provide 2 setters.
Is there a good document somewhere that can get me going? Not that SIA isn't good, but I'm obviously missing something.
Thanks for any pointers.
Colin