Compare commits

..

No commits in common. "07f93f329f0c02bd56d85d0caf2f9cb26afbf12d" and "3a4053e079bbea6ccb8e989821ddd75d18aecc86" have entirely different histories.

7 changed files with 10 additions and 129 deletions

View File

@ -1,68 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bdd;
import java.sql.Connection;
import java.sql.DriverManager;
/**
*
* @author clementine.desrucques
*/
public class Connexion {
private static Connection connect; // Variable de connexion
/**
* Constructeur
* @param serveur nom du serveur, localhost si local
* @param bdd nom de la base de données
* @param nomUtil nom utilisateur
* @param mdp mot de passe lié à l'utilisateur
*/
private Connexion(String serveur, String bdd, String nomUtil, String mdp) {
try {
// 1. Chargement du driver
//Class.forName("com.mysql.jdbc.Driver");
Class.forName("com.mysql.cj.jdbc.Driver");
System.out.println("Driver accessible");
// 2. Initialisation des paramètres de connexion
String host = serveur; // Serveur de bd
String dbname = bdd; // Nom bd
String url = "jdbc:mysql://" + host + "/" + dbname; // url de connexion
//url += "?autoReconnect=true"; // Ajout 26/09/2021
System.out.println("url : "+url);
String user = nomUtil; // nom du user
System.out.println("nomUtil : "+nomUtil);
String passwd = mdp; // mot de passe
System.out.println("mdp : "+mdp);
// 3. Connexion
connect = (Connection) DriverManager.getConnection(url, user, passwd);
System.out.println("Connexion réussie !");
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Retourne la connection établie (Création d'une connection si elle n'existe pas)
* @param serveur nom du serveur, localhost si local
* @param bdd nom de la base de données
* @param nomUtil nom utilisateur
* @param mdp mot de passe lié à l'utilisateur
* @return connection établie
*/
public static Connection getConnect(String serveur, String bdd, String nomUtil, String mdp) {
System.out.println("getConnect");
if (connect == null) {
new Connexion(serveur, bdd, nomUtil, mdp);
}
return connect;
}
}

View File

@ -1,14 +0,0 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package bdd;
/**
*
* @author clementine.desrucques
*/
public class PompierMySql {
}

View File

@ -26,11 +26,6 @@ public class Pompier {
private String adrVille;
private 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) {
this(idCaserne, nom, prenom, statut, mail, login, mdp, adrNo, adrRue, adrCP, adrVille, grade);
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) {
this.idCaserne = idCaserne;
this.nom = nom;
@ -46,6 +41,10 @@ public class Pompier {
this.grade = 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) {
this(idCaserne, nom, prenom, statut, mail, login, mdp, adrNo, adrRue, adrCP, adrVille, grade);
this.id = id;
}
public int getId() {
return id;

View File

@ -44,8 +44,7 @@ public class NouveauPompForm {
if (erreur > 0) return -1;
// Creation d'un objet de type Client avec les données transmises
Pompier unPompier = new Pompier(
request.getParameter("idCaserne"),
Pompier unPompier = new Pompier(request.getParameter("idCaserne"),
request.getParameter("ztNom"),
request.getParameter("ztPrenom"),
request.getParameter("statut"),
@ -56,14 +55,13 @@ public class NouveauPompForm {
request.getParameter("ztRue"),
request.getParameter("ztCP"),
request.getParameter("ztVille"),
request.getParameter("grade")
);
request.getParameter("grade"));
ClientMysql cm = new ClientMysql();
int id = cm.createRP(unPompier); // Requête préparée
if (id == -1) {
int idClient = cm.createRP(unPompier); // Requête préparée
if (idClient == -1) {
message = "Erreur lors de la création du client";
}
return id;
return idClient;
}

View File

@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/ProjetSDIS29_2"/>
<Context path="/ProjetSDIS29_2/Authentification"/>

View File

@ -1,17 +0,0 @@
<%--
Document : CreaPompier
Created on : 18 oct. 2021, 15:49:36
Author : clementine.desrucques
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>

View File

@ -1,17 +0,0 @@
<%--
Document : ModifPompier
Created on : 18 oct. 2021, 15:49:00
Author : clementine.desrucques
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>