================================== 删除单条账户记录,返回受影响的行数 ================================== 实现数据访问接口方法: // 针对t_account表的数据访问接口实现 @Repository public class AccountDao implements IAccountDao { @Resource // 注入JDBC模板 private JdbcTemplate jdbcTemplate; ... // 删除单条账户记录,返回受影响的行数 @Override public int deleteAccount(int accountId) { // 定义SQL语句 String sql = "delete from t_account where account_id = ?"; // 执行SQL语句 int nrows = jdbcTemplate.update(sql, accountId); // 返回受影响的行数 return nrows; } ... } 编写测试用例: // 删除账户记录测试类 public class SpringJDBCTestDelete extends SpringJDBCTest { @Resource // 注入数据访问对象 private IAccountDao accountDao; ... // 测试:删除单条账户记录,返回受影响的行数 @Test public void testDeleteAccount() { // 删除单条账户记录,返回受影响的行数 int nrows = accountDao.deleteAccount(3); System.out.println(getClass().getName() + "." + Thread .currentThread().getStackTrace()[1].getMethodName() + ": " + nrows); } ... } 运行测试用例: cn.tedu.springjdbc.test.SpringJDBCTestDelete.testDeleteAccount: 1 看库。