public LogForm queryCarLogForm(Integer car_id) { String sql = "select * from tb_carlog where car_id=" + car_id + ""; ResultSet rs = connection.executeQuery(sql); logForm = null; try { while (rs.next()) { logForm = new LogForm(); logForm.setId(rs.getInt(1)); logForm.setGoods_id(rs.getString(2)); logForm.setCar_id(rs.getString(3)); logForm.setStartTime(rs.getString(4)); logForm.setEndTime(rs.getString(5)); logForm.setDescribe(rs.getString(6)); } } catch (SQLException e) { e.printStackTrace(); } return logForm; }
public static void main(String[] args) { GoodsAndLogDao dao = new GoodsAndLogDao(); LogForm form = dao.queryCarLogForm(4); System.out.println(form.getId()); }