try {
Statement statement = con.createStatement();
// Checks if the person already exists in the database by using the id.
String sql = "SELECT * FROM Person WHERE id = '" + id + "'";
ResultSet rs = statement.executeQuery(sql);
Person person = null;
if (rs.next()) {
// finds the person int the database
Person father = null;
String fatherId = rs.getString("fatherId");
if (!fatherId.trim().equals("P-NULL")) {
father = getPerson(fatherId);
}
Person mother = null;
String motherId = rs.getString("fatherId");
if (!motherId.trim().equals("P-NULL")) {
mother = getPerson(motherId);
}
person =
new Person(father, mother, rs.getString("firstname"),
rs.getString("surname"), rs.getBoolean("sex"));
StringBuilder childrenSQL = new StringBuilder();
String string = rs.getString("children");
if (string != null) {
childrenSQL.append(string);