This commit is contained in:
clementine.desrucques 2021-10-20 11:56:07 +02:00
parent 75c661ec0c
commit 26c4272163
4 changed files with 70 additions and 10 deletions

View File

@ -32,6 +32,47 @@ public class PompierMySql {
"minda"); // mot de passe ClientMysql() { "minda"); // mot de passe ClientMysql() {
} }
/**
* Recherche de tous les clients
* @return collection de clients
*/
public ArrayList<Pompier> readAll() {
ArrayList<Pompier> lesPompiers = new ArrayList<>();
try {
Statement stmt = theConnection.createStatement();
ResultSet resultQ = null;
resultQ = stmt.executeQuery("SELECT * FROM pompier");
while (resultQ.next()) {
unPompier = new Pompier(resultQ.getInt("id"),
resultQ.getInt("idCaserne"),
resultQ.getString("nom"),
resultQ.getString("prenom"),
resultQ.getInt("statut"),
resultQ.getString("mail"),
resultQ.getString("login"),
resultQ.getString("mdp"),
resultQ.getInt("adrNo"),
resultQ.getString("adrRue"),
resultQ.getString("adrCP"),
resultQ.getString("adrVille"),
resultQ.getInt("grade"),
resultQ.getString("commentaire")
);
lesPompiers.add(unPompier);
}
resultQ.close();
stmt.close();
//theConnection.close();
} catch (SQLException ex) {
System.out.println("SQLException : " + ex.getMessage());
System.out.println("SQLState : " + ex.getSQLState());
System.out.println("Code erreur : " + ex.getErrorCode());
}
return lesPompiers;
}
/** /**
* Creation du pompier passé en paramètre dans la table pompier * Creation du pompier passé en paramètre dans la table pompier
* Requête non préparée * Requête non préparée

View File

@ -25,13 +25,14 @@ public class Pompier {
private String adrCP; private String adrCP;
private String adrVille; private String adrVille;
private int grade; private int grade;
private String commentaire;
public Pompier(int id, int idCaserne, String nom, String prenom, int statut, String mail, String login, String mdp, int adrNo, String adrRue, String adrCP, String adrVille, int grade) { public Pompier(int id, int idCaserne, String nom, String prenom, int statut, String mail, String login, String mdp, int adrNo, String adrRue, String adrCP, String adrVille, int grade, String commentaire) {
this(idCaserne, nom, prenom, statut, mail, login, mdp, adrNo, adrRue, adrCP, adrVille, grade); this(idCaserne, nom, prenom, statut, mail, login, mdp, adrNo, adrRue, adrCP, adrVille, grade, commentaire);
this.id = id; this.id = id;
} }
public Pompier(int idCaserne, String nom, String prenom, int statut, String mail, String login, String mdp, int adrNo, String adrRue, String adrCP, String adrVille, int grade) { public Pompier(int idCaserne, String nom, String prenom, int statut, String mail, String login, String mdp, int adrNo, String adrRue, String adrCP, String adrVille, int grade, String commentaire) {
this.idCaserne = idCaserne; this.idCaserne = idCaserne;
this.nom = nom; this.nom = nom;
this.prenom = prenom; this.prenom = prenom;
@ -44,9 +45,9 @@ public class Pompier {
this.adrCP = adrCP; this.adrCP = adrCP;
this.adrVille = adrVille; this.adrVille = adrVille;
this.grade = grade; this.grade = grade;
this.commentaire = commentaire;
} }
public int getId() { public int getId() {
return id; return id;
} }
@ -151,9 +152,17 @@ public class Pompier {
this.grade = grade; this.grade = grade;
} }
public String getCommentaire() {
return commentaire;
}
public void setCommentaire(String commentaire) {
this.commentaire = commentaire;
}
@Override @Override
public int hashCode() { public int hashCode() {
int hash = 7; int hash = 3;
hash = 29 * hash + this.id; hash = 29 * hash + this.id;
hash = 29 * hash + this.idCaserne; hash = 29 * hash + this.idCaserne;
hash = 29 * hash + Objects.hashCode(this.nom); hash = 29 * hash + Objects.hashCode(this.nom);
@ -167,6 +176,7 @@ public class Pompier {
hash = 29 * hash + Objects.hashCode(this.adrCP); hash = 29 * hash + Objects.hashCode(this.adrCP);
hash = 29 * hash + Objects.hashCode(this.adrVille); hash = 29 * hash + Objects.hashCode(this.adrVille);
hash = 29 * hash + this.grade; hash = 29 * hash + this.grade;
hash = 29 * hash + Objects.hashCode(this.commentaire);
return hash; return hash;
} }
@ -221,13 +231,17 @@ public class Pompier {
if (!Objects.equals(this.adrVille, other.adrVille)) { if (!Objects.equals(this.adrVille, other.adrVille)) {
return false; return false;
} }
if (!Objects.equals(this.commentaire, other.commentaire)) {
return false;
}
return true; return true;
} }
@Override @Override
public String toString() { public String toString() {
return "Pompier{" + "id=" + id + ", idCaserne=" + idCaserne + ", nom=" + nom + ", prenom=" + prenom + ", statut=" + statut + ", mail=" + mail + ", login=" + login + ", mdp=" + mdp + ", adrNo=" + adrNo + ", adrRue=" + adrRue + ", adrCP=" + adrCP + ", adrVille=" + adrVille + ", grade=" + grade + '}'; return "Pompier{" + "id=" + id + ", idCaserne=" + idCaserne + ", nom=" + nom + ", prenom=" + prenom + ", statut=" + statut + ", mail=" + mail + ", login=" + login + ", mdp=" + mdp + ", adrNo=" + adrNo + ", adrRue=" + adrRue + ", adrCP=" + adrCP + ", adrVille=" + adrVille + ", grade=" + grade + ", commentaire=" + commentaire + '}';
} }
} }

View File

@ -42,10 +42,14 @@ public class AuthentifForm {
/* Comparaison entre l'utilisateur admin et un utilisateur créé /* Comparaison entre l'utilisateur admin et un utilisateur créé
avec le pseudo et le mdp saisi */ avec le pseudo et le mdp saisi */
// UserP ChefCaserne = new UserP("Michel", "mRANN"); // UserP ChefCaserne = new UserP("Michel", "mRANN");
UserP userSaisi = new UserP( request.getParameter("ztPseudo"), Statement stmt = theConnection.createStatement();
ResultSet resultQ = null;
resultQ = stmt.executeQuery("SELECT * FROM pompier WHERE login=);
boolean isChef=false;
Pompier userSaisi = new Pompier( request.getParameter("ztPseudo"),
request.getParameter("ztMDP")); request.getParameter("ztMDP"));
if(request.getParameter("ztPseudo").equals(request)){ if(request.getParameter("ztPseudo").equals(request)){
boolean isChef = userSaisi; isChef=true;
} }
// Mise à jour de l'attribut resultat // Mise à jour de l'attribut resultat
setResultat(isChef ? "Vous êtes chef de caserne" : "Vous n'êtes pas chef de caserne"); setResultat(isChef ? "Vous êtes chef de caserne" : "Vous n'êtes pas chef de caserne");

View File

@ -5,6 +5,7 @@
--%> --%>
<%@include file = "jspf/enteteJSPF.jspf" %> <%@include file = "jspf/enteteJSPF.jspf" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -48,7 +49,7 @@
<td><c:out value="${unPompier.getAdrCP()}"/></td> <td><c:out value="${unPompier.getAdrCP()}"/></td>
<td><c:out value="${unPompier.getAdrVille()}"/></td> <td><c:out value="${unPompier.getAdrVille()}"/></td>
<td><c:out value="${unPompier.getGrade()}"/></td> <td><c:out value="${unPompier.getGrade()}"/></td>
<td><c:out value="${unPompier.getCom()}"/></td> <td><c:out value="${unPompier.getCommentaire()}"/></td>
</tr> </tr>
</c:forEach> </c:forEach>