summaryrefslogtreecommitdiff
path: root/src/DAO_Test.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/DAO_Test.java')
-rw-r--r--src/DAO_Test.java21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/DAO_Test.java b/src/DAO_Test.java
index aa6a0af..673f2b7 100644
--- a/src/DAO_Test.java
+++ b/src/DAO_Test.java
@@ -6,21 +6,34 @@ import dao.JDBC;
6import dao.ResultObject; 6import dao.ResultObject;
7import dao.SQLexecutor; 7import dao.SQLexecutor;
8 8
9/*
10 * fonction main pour tester des commandes
11 */
9public class DAO_Test 12public class DAO_Test
10{ 13{
11 public static void main(String[] args) throws SQLException, ClassNotFoundException 14 public static void main(String[] args) throws SQLException, ClassNotFoundException
12 { 15 {
16 // envoie de tous les paramètres en même temps
13 JDBC.setInfos("localhost", "mysql", "tp", "root", ""); 17 JDBC.setInfos("localhost", "mysql", "tp", "root", "");
18
19 // même chose avec envoie un par un
20 // si un paramètre doit être modifié à la volée, faire un JDBC.setStrUlr(); après
21 JDBC.setHost("localhost");
22 JDBC.setDBMS("mysql");
23 JDBC.setDbName("tp");
24 JDBC.setLogin("root");
25 JDBC.setPassword("");
26 JDBC.setStrUrl();
27
14 SQLexecutor executor = new SQLexecutor(); 28 SQLexecutor executor = new SQLexecutor();
15 29
16 // SELECT 30 // SELECT
17 ResultObject result = executor.executeQuery("SELECT * FROM acces WHERE id = ?", 1); 31 ResultObject result = executor.executeQuery("SELECT * FROM acces WHERE id = ?", 1);
18 for(HashMap<String, Object> row : result.getData()) 32 for(HashMap<String, Object> row : result.getData()) // foreach sur les entrées
19 { 33 {
20 System.out.println("prenom: " + row.get("prenom")); // une entrée 34 System.out.println("prénom: " + row.get("prenom")); //un champ d'une entrée
21 35
22 // foreach sur toutes les entrées 36 for(HashMap.Entry<String, Object> one_field : row.entrySet()) // foreach sur les champs
23 for(HashMap.Entry<String, Object> one_field : row.entrySet())
24 { 37 {
25 System.out.print(one_field.getKey() + ": " + one_field.getValue() + "\n"); 38 System.out.print(one_field.getKey() + ": " + one_field.getValue() + "\n");
26 } 39 }