================================== 修改指定账户记录,返回受影响的行数 ================================== 实现数据访问接口方法: // 针对t_account表的数据访问接口实现 @Repository public class AccountDao implements IAccountDao { @Resource // 注入JDBC模板 private JdbcTemplate jdbcTemplate; ... // 修改指定账户记录,返回受影响的行数 @Override public int modifyAccount(Account account) { // 定义SQL语句 String sql = "update t_account set account_name = ?, " + "account_type = ?, money = ?, remark = ?, " + "update_time = now(), user_id = ? where account_id = ?"; // 设置参数 Object[] args = {account.getAccountName(), account.getAccountType(), account.getMoney(), account.getRemark(), account.getUserId(), account.getAccountId()}; // 执行SQL语句 int nrows = jdbcTemplate.update(sql, args); // 返回受影响的行数 return nrows; } ... } 编写测试用例: // 修改账户记录测试类 public class SpringJDBCTestModify extends SpringJDBCTest { @Resource // 注入数据访问对象 private IAccountDao accountDao; ... // 测试:修改指定账户记录,返回受影响的行数 @Test public void testModifyAccount() { // 准备单条账户记录 Account account = new Account( 2, "9558860936", "工商银行广州分行", 30000.0, "收益", 1); // 修改指定账户记录,返回受影响的行数 int nrows = accountDao.modifyAccount(account); System.out.println(getClass().getName() + "." + Thread .currentThread().getStackTrace()[1].getMethodName() + ": " + nrows); } ... } 运行测试用例: cn.tedu.springjdbc.test.SpringJDBCTestModify.testModifyAccount: 1 看库。