Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Car {
- private String color, brand;
- public Car(String color, String brand) {
- this.color = color;
- this.brand = brand;
- }
- public void setColor(String color){
- this.color = color;
- }
- public String getColor(){
- return color;
- }
- public void setBrand(String brand) {
- this.brand = brand;
- }
- public String getBrand() {
- return brand
- }
- }
- public List<Car> getCars() {
- List<Car> listOfCars = new LinkedList<>();
- String query = "select * from cars";
- Connection connection = {get connection here};
- ...
- while (resultSet.next()) {
- String color = resultSet.getString("color");
- String brand = resultSet.getString("brand");
- Car car = new Car(color, brand);
- listOfCars.add(car);
- }
- return listOfCars;
- }
Add Comment
Please, Sign In to add comment