/* pour tester les classes */ import java.sql.SQLException; import java.util.HashMap; import dao.JDBC; import dao.ResultObject; import dao.SQLexecutor; public class DAO_Test { public static void main(String[] args) throws SQLException, ClassNotFoundException { JDBC.setInfos("localhost", "mysql", "tp", "root", ""); SQLexecutor executor = new SQLexecutor(); // SELECT ResultObject result = executor.executeQuery("SELECT * FROM acces WHERE id = ?", 1); for(HashMap row : result.getData()) { System.out.println("prenom: " + row.get("prenom")); // une entrée // foreach sur toutes les entrées for(HashMap.Entry one_field : row.entrySet()) { System.out.print(one_field.getKey() + ": " + one_field.getValue() + "\n"); } } // INSERT executor.executeQuery("INSERT INTO acces (prenom, login, password, statut, age) VALUES (?, ?, ?, ?, ?)", "Dylan", "Toto", "Titi", "Etudiant", 22); // UPDATE executor.executeQuery("UPDATE acces SET statut = ? WHERE prenom = ?", "joue à fortnite", "Dylan"); // DELETE executor.executeQuery("DELETE FROM acces WHERE prenom = ?", "Dylan"); } }