Guest User

Untitled

a guest
Jun 24th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. public class Car {
  2.  
  3. private String color, brand;
  4.  
  5. public Car(String color, String brand) {
  6. this.color = color;
  7. this.brand = brand;
  8. }
  9.  
  10. public void setColor(String color){
  11. this.color = color;
  12. }
  13.  
  14. public String getColor(){
  15. return color;
  16. }
  17.  
  18. public void setBrand(String brand) {
  19. this.brand = brand;
  20. }
  21.  
  22. public String getBrand() {
  23. return brand
  24. }
  25.  
  26.  
  27. }
  28.  
  29. public List<Car> getCars() {
  30.  
  31. List<Car> listOfCars = new LinkedList<>();
  32. String query = "select * from cars";
  33. Connection connection = {get connection here};
  34.  
  35. ...
  36.  
  37. while (resultSet.next()) {
  38.  
  39. String color = resultSet.getString("color");
  40. String brand = resultSet.getString("brand");
  41. Car car = new Car(color, brand);
  42. listOfCars.add(car);
  43. }
  44. return listOfCars;
  45.  
  46. }
Add Comment
Please, Sign In to add comment