public static boolean updateContactUrgence(ContactUrgence contact) throws Exception { Connection con; ConnexionBd connexionBD = new ConnexionBd(); boolean updateOk = false; con = connexionBD.createConnection(); try { String sqlString = "Update contact_urgence " + " Set nom = " + contact.getNom() + ", prenom = " + contact.getPrenom() + ", courriel = " + contact.getCourriel() + ", id_relation = " + contact.getRelation().getId() + " Where id = " + contact.getId(); updateOk = connexionBD.executeSQL(con, sqlString); if (!updateOk) { System.err.println("***To update the data row ...." + sqlString); } } catch (SQLException e) { System.err.println("***** Database error at updateContactUrgence: " + e.getMessage()); } con.close(); System.out.println("Connection closed"); return updateOk; }
public static boolean insertOneContact(ContactUrgence contact) throws Exception { Connection con; ConnexionBd connexionBD = new ConnexionBd(); boolean insertOk = false; con = connexionBD.createConnection(); try { String sqlString = "insert into contact_urgence " + "(id, nom, prenom, courriel, id_relation) " + "values (" + contact.getId() + ", '" + contact.getNom() + "', '" + contact.getPrenom() + "', '" + contact.getCourriel() + "', '" + contact.getRelation().getId() + "')"; insertOk = connexionBD.executeSQL(con, sqlString); if (!insertOk) { System.err.println("***To insert the data row ...." + sqlString); } } catch (SQLException e) { System.err.println("***** Database error at insertOneContact: " + e.getMessage()); } con.close(); System.out.println("Connection closed"); return insertOk; }