@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);
}
}
备忘于此