### Question:
CmdDaoImpl implements CmdDao { @Override public List<Key> queryKeyList(int deviceId) { String sql = "select * from cmd where device_id = ?"; SqlRowSet row = template.queryForRowSet(sql, new Object[]{deviceId}); List<Key> keys = new ArrayList<>(); Key key = null; while (row.next()) { key = new Key(); key.setDeviceId(deviceId); key.setCmd(row.getString("cmd")); key.setName(row.getString("name")); key.setData(row.getString("data")); keys.add(key); } return keys; }  JdbcTemplate getTemplate(); void setTemplate(JdbcTemplate template); @Override Key queryKey(int deviceId, String cmd); @Override void updateKey(Key key); @Override void insert(List<Key> keys); @Override List<Key> queryKeyList(int deviceId);  }### Answer:
@Test public void queryKeyList() throws Exception { List<Key> keys = cmdDao.queryKeyList(1); for (Key key : keys) { System.out.println(key.getName() + ":" + key.getCmd()); } }