1、SQL语句拼接
//1)根据名称模糊查询账户信息,可以返回多个记录
public List<Account> getAccountByLike(String name) {
String sql="select * from account where name like '%"+name+"%'";
List<Account> accountList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Account.class));
return accountList;
}
2、测试:
@Test
public void test06()
{
List<Account> accountList=accountDao.getAccountByLike("白");
for(Account account:accountList)
{
System.out.println("account="+account);
}
}