首页 > 代码库 > 如何使用 AutoWire方式注入 JdbcDaoSupport DataSource

如何使用 AutoWire方式注入 JdbcDaoSupport DataSource

 
@Repository
public class MyDaoImpl extends JdbcDaoSupport implements MyDao {
@Autowired
private DataSource dataSource;

@PostConstruct
private void initialize() {
setDataSource(dataSource);
}

public void In(String user, double money) {
String sql = "update account set money = money + " + money + " where name=‘" + user + "‘";

this.getJdbcTemplate().update(sql);

}

public void Out(String user, double money) {
String sql = "update account set money = money - ? where name=?";

this.getJdbcTemplate().update(sql, money, user);
}
}
备忘于此

如何使用 AutoWire方式注入 JdbcDaoSupport DataSource