We will start with CRUD operations by using the PostgreSQL database and the class Person1:
public class Person1 { private int id; private int age; private String name; public Person1(){} //Must be present, used by the framework public Person1(int age, String name){ this.age = age; this.name = name; } public int getId() { return id; } public void setName(String name) { this.name = name; } @Override public String toString() { return "Person1{id=" + id + ", age=" + age + ", name='" + name + "'}"; }}
We need the previous getId() method to get an ID value (to demonstrate how to find a database record by ID). The method setName() will be used to update the database record, and the method toString() will be used to display the results. ...