diff --git a/src/java/bdd/PompierMySql.java b/src/java/bdd/PompierMySql.java
index 4a3af80..a2f6381 100644
--- a/src/java/bdd/PompierMySql.java
+++ b/src/java/bdd/PompierMySql.java
@@ -50,21 +50,24 @@ public class PompierMySql {
ResultSet resultQ = null;
resultQ = stmt.executeQuery("SELECT * FROM pompier");
while (resultQ.next()) {
- unPompier = new Pompier(resultQ.getInt("id"),
+ unPompier = new Pompier (resultQ.getInt("id"),
resultQ.getInt("idCaserne"),
resultQ.getString("nom"),
resultQ.getString("prenom"),
resultQ.getInt("statut"),
+ resultQ.getInt("typePers"),
resultQ.getString("mail"),
resultQ.getString("login"),
resultQ.getString("mdp"),
- resultQ.getInt("adrNo"),
- resultQ.getString("adrRue"),
- resultQ.getString("adrCP"),
- resultQ.getString("adrVille"),
+ resultQ.getString("adresse"),
+ resultQ.getString("cp"),
+ resultQ.getString("ville"),
+ resultQ.getString("bip"),
+ resultQ.getInt("nbGardes"),
resultQ.getInt("grade"),
resultQ.getString("commentaire")
- );
+ resultQ.getInt("idEmployeur")
+ );
lesPompiers.add(unPompier);
}
resultQ.close();
@@ -79,47 +82,6 @@ public class PompierMySql {
return lesPompiers;
}
- /**
- * Creation du pompier passé en paramètre dans la table pompier Requête non
- * préparée
- *
- * @param p objet de type Pompier (sans identifiant)
- * @return int : id du Pompier créé
- */
- public int create(Pompier p) {
- int id = -1;
- try {
- Statement stmt = theConnection.createStatement();
- int status = stmt.executeUpdate(
- "INSERT INTO pompier (idCaserne, nom, prenom, statut, mail, login, mdp, adrNo, adrRue, adrCP, adrVille, grade) "
- + "VALUES ('" + p.getIdCaserne() + "', '"
- + p.getNom() + "', '"
- + p.getPrenom() + "', '"
- + p.getStatut() + "', "
- + p.getMail() + ", '"
- + p.getLogin() + ", '"
- + p.getMdp() + ", '"
- + p.getAdrNo() + ", '"
- + p.getAdrRue() + "', '"
- + p.getAdrCP() + "', '"
- + p.getAdrVille() + "', '"
- + p.getGrade() + "' );",
- Statement.RETURN_GENERATED_KEYS);
-
- // Recherche de l'identifiant du pompier créé
- if (status > 0) {
- ResultSet result = stmt.getGeneratedKeys();
- if (result.first()) {
- id = result.getInt(1);
- }
- }
- } catch (SQLException ex) {
- System.out.println("SQLException : " + ex.getMessage());
- System.out.println("SQLState : " + ex.getSQLState());
- System.out.println("Code erreur : " + ex.getErrorCode());
- }
- return id;
- }
/**
* Creation du pompier passé en paramètre dans la table pompier Requête
@@ -132,7 +94,7 @@ public class PompierMySql {
int id = -1;
try {
PreparedStatement stmt = null;
- String sql = "INSERT INTO pompier(idCaserne, nom, prenom, statut, mail, login, mdp, adrNo, adrRue, adrCP, adrVille, grade) "
+ String sql = "INSERT INTO pompier(idCaserne, nom, prenom, statut, typePers, mail, login, mdp, adresse, cp, ville, bip, nbGardes, grade, commentaire, idEmployeur) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?);";
stmt = theConnection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
stmt.setInt(1, p.getIdCaserne());
@@ -173,21 +135,37 @@ public class PompierMySql {
String mdp = request.getParameter("ztMDP");
String mdpChiffre = MD5.encode(request.getParameter("ztMDP"));
String sql = "SELECT * FROM pompier WHERE login='" + login + "' AND mdp='" + mdpChiffre + "';";
- System.out.println("sql:"+sql);
+ System.out.println("sql:" + sql);
try {
Statement stmt = theConnection.createStatement();
ResultSet resultQ = null;
resultQ = stmt.executeQuery(sql);
resultat = (resultQ.next());
-// if(resultat){
-// Pompier lePompier = new Pompier(
-// resultQ.getInt("id"),
-// resultQ.getInt("idCAserne"),
-//
-// );
-// HttpSession maSession = request.getSession();
-// maSession.setAttribute("lePompier", lePompier);
-// }
+ if (resultat) {
+ Pompier lePompier = new Pompier(
+ resultQ.getInt("id"),
+ resultQ.getInt("idCaserne"),
+ resultQ.getString("nom"),
+ resultQ.getString("prenom"),
+ resultQ.getInt("statut"),
+ resultQ.getInt("typePers"),
+ resultQ.getString("mail"),
+ resultQ.getString("login"),
+ resultQ.getString("mdp"),
+ resultQ.getString("adresse"),
+ resultQ.getString("cp"),
+ resultQ.getString("ville"),
+ resultQ.getString("bip"),
+ resultQ.getInt("nbGardes"),
+ resultQ.getInt("grade"),
+ resultQ.getString("commentaire"),
+ resultQ.getInt("idEmployeur"),
+
+ );
+ HttpSession maSession = request.getSession();
+ maSession.setAttribute("unPompier", lePompier);
+ System.out.println("lePompier :"+ lePompier);
+ }
} catch (SQLException ex) {
Logger.getLogger(PompierMySql.class.getName()).log(Level.SEVERE, null, ex);
diff --git a/src/java/com/test/forms/AuthentifForm.java b/src/java/com/test/forms/AuthentifForm.java
index bc8170f..b763ece 100644
--- a/src/java/com/test/forms/AuthentifForm.java
+++ b/src/java/com/test/forms/AuthentifForm.java
@@ -39,20 +39,16 @@ public class AuthentifForm {
* @param request
* @return true is ok, false sinon
*/
-
public boolean controlerRole(HttpServletRequest request) {
/* Comparaison entre l'utilisateur saisi et un utilisateur de la base de donées */
// UserP ChefCaserne = new UserP("Michel", "mRANN");
-
-
PompierMySql pm = new PompierMySql();
boolean resul = pm.isAuthentified(request);
resultat = resul?"":"Pseudo ou mdp incorrect";
return resul;
// Mise à jour de l'attribut resultat
-
-
+
}
}
diff --git a/src/java/com/test/forms/NouveauPompForm.java b/src/java/com/test/forms/NouveauPompForm.java
index 0c96ab2..b21a715 100644
--- a/src/java/com/test/forms/NouveauPompForm.java
+++ b/src/java/com/test/forms/NouveauPompForm.java
@@ -47,19 +47,20 @@ public class NouveauPompForm {
// Creation d'un objet de type Client avec les données transmises
- Pompier unPompier = new Pompier(request.getParameter("id"),
+ Pompier unPompier = new Pompier(
+ request.getParameter("id"),
request.getParameter("idCaserne"),
- request.getParameter("ztNom"),
- request.getParameter("ztPrenom"),
- request.getParameter("nStatut"),
- request.getParameter("eMail"),
- request.getParameter("ztLogin"),
- request.getParameter("ztMDP"),
+ request.getParameter("nom"),
+ request.getParameter("prenom"),
+ request.getParameter("statut"),
+ request.getParameter("mail"),
+ request.getParameter("login"),
+ request.getParameter("mdp"),
noRue,
- request.getParameter("ztAdrRue"),
- request.getParameter("ztAdrCP"),
- request.getParameter("ztAdrVille"),
- request.getParameter("nGrade"),
+ request.getParameter("adrRue"),
+ request.getParameter("adrCP"),
+ request.getParameter("adrVille"),
+ request.getParameter("grade"),
request.getParameter("commentaire")
);
PompierMySql cm = new PompierMySql();
diff --git a/src/java/com/test/servlets/ModifPompierServlet.java b/src/java/com/test/servlets/ModifPompierServlet.java
index 2b22b5c..95f3a11 100644
--- a/src/java/com/test/servlets/ModifPompierServlet.java
+++ b/src/java/com/test/servlets/ModifPompierServlet.java
@@ -5,6 +5,7 @@
*/
package com.test.servlets;
+import bdd.PompierMySql;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
@@ -57,8 +58,15 @@ public class ModifPompierServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- PompierMysql PompierMs = new PompierMySql();
- request.setAttribute("unPompier", PomperMs.readAll());
+ PompierMySql PompierMs = new PompierMySql();
+
+
+
+
+
+
+
+
processRequest(request, response);
}
diff --git a/src/java/com/test/servlets/authentifServlet.java b/src/java/com/test/servlets/authentifServlet.java
index 6439bf6..6c97caa 100644
--- a/src/java/com/test/servlets/authentifServlet.java
+++ b/src/java/com/test/servlets/authentifServlet.java
@@ -79,14 +79,16 @@ public class authentifServlet extends HttpServlet {
AuthentifForm leControle = new AuthentifForm();
// Appel de la méthode controlerRole
boolean isAuthentified = leControle.controlerRole(request);
- // Création de 2 attributs de requête (isChef et leControle)
+ // Création de 2 attributs de requête (isAuthentified et leControle)
request.setAttribute("isAuthentified", isAuthentified);
request.setAttribute("controlForm", leControle);
HttpSession maSession = request.getSession();
maSession.setAttribute("isAuthentified", true);
+
// Affichage de la JSP
if(isAuthentified==true){
- getServletContext().getRequestDispatcher("/WEB-INF/PompierJSP.jsp")
+ System.out.println("Ma session : "+maSession.getAttribute("unPompier"));
+ getServletContext().getRequestDispatcher("/WEB-INF/ModifPompier.jsp")
.forward(request, response);
}else{
getServletContext().getRequestDispatcher("/WEB-INF/accueilJSP.jsp")
diff --git a/web/WEB-INF/CreaPompier.jsp b/web/WEB-INF/CreaPompier.jsp
index 55f6a01..f8f7d0a 100644
--- a/web/WEB-INF/CreaPompier.jsp
+++ b/web/WEB-INF/CreaPompier.jsp
@@ -28,7 +28,7 @@
-
+ resultQ.getInt("idEmployeur"),
@@ -40,8 +40,7 @@
-
-