如何使用 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);
}
}
备忘于此
posted @ 2017-03-10 13:59  张保维  阅读(1448)  评论(0编辑  收藏  举报