...
 
Commits (3)
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/web" relative="/" />
</webroots>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Tomcat 9.0.311" level="application_server_libraries" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
</web-app>
\ No newline at end of file
<%--
Created by IntelliJ IDEA.
User: michael
Date: 19/02/2020
Time: 15:12
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java"
import="java.util.*, java.text.SimpleDateFormat"
%>
<html>
<head>
<title>$Title$</title>
</head>
<body>
<h1>TP1</h1>
<p>
Mois :
<%
// ------ NE PAS OUBLIER D'APPELER LA BIBLIOTHEQUE JAVA.UTIL.* -------
//Metier
Calendar maintenant = Calendar.getInstance();
int nb = maintenant.get(Calendar.MONTH) + 1;
//Affichage resultat
out.println(nb);
System.out.println("numero du prochain mois : " + nb);
%>
</p>
<p>
Date du jour :
<%
SimpleDateFormat formatter = new SimpleDateFormat("dd-MMMM-yyyy HH:mm:ss");
Date now = maintenant.getTime();
out.println(formatter.format(now));
%>
</p>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
</web-app>
\ No newline at end of file
<%--
Created by IntelliJ IDEA.
User: michael
Date: 19/02/2020
Time: 15:12
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java"
import="java.util.*, java.text.SimpleDateFormat"
%>
<html>
<head>
<title>TP</title>
</head>
<body>
<h1>TP1</h1>
<p>
Mois :
<%
// ------ NE PAS OUBLIER D'APPELER LA BIBLIOTHEQUE JAVA.UTIL.* -------
//Metier
Calendar maintenant = Calendar.getInstance();
int nb = maintenant.get(Calendar.MONTH) + 1;
//Affichage resultat
out.println(nb);
System.out.println("numero du prochain mois : " + nb);
%>
</p>
<p>
Date du jour :
<%
SimpleDateFormat formatter = new SimpleDateFormat("dd-MMMM-yyyy HH:mm:ss");
Date now = maintenant.getTime();
out.println(formatter.format(now));
%>
</p>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/web" relative="/" />
</webroots>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Tomcat 9.0.311" level="application_server_libraries" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
</web-app>
\ No newline at end of file
<%--
Created by IntelliJ IDEA.
User: michael
Date: 19/02/2020
Time: 15:40
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
</head>
<body>
<title>Affichage nom et prenom</title>
<p>
Bonjour <%= request.getParameter("nom")%>
, <%= request.getParameter("pass")%>
</p>
<%
//metier
String nom = request.getParameter("nom");
String pass = request.getParameter("pass");
String etat = "inconnue";
if(nom.equals("michael") && pass.equals("tiger"))
{
etat = "connu";
}
%>
vous etes <%= etat %>
</body>
</html>
<%--
Created by IntelliJ IDEA.
User: michael
Date: 19/02/2020
Time: 15:35
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>$Title$</title>
</head>
<body>
<form methode="POST" action="affiche.jsp">
Nom :
<input type="text" name="nom">
<br />
Mot de passe :
<input type="text" name="pass">
<br />
<input type="submit" name="ok" value="Envoyer">
</form>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
</web-app>
\ No newline at end of file
<%--
Created by IntelliJ IDEA.
User: michael
Date: 19/02/2020
Time: 15:40
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
</head>
<body>
<title>Affichage nom et prenom</title>
<p>
Bonjour <%= request.getParameter("nom")%>
, <%= request.getParameter("pass")%>
</p>
<%
//metier
String nom = request.getParameter("nom");
String pass = request.getParameter("pass");
String etat = "inconnue";
if(nom.equals("michael") && pass.equals("tiger"))
{
etat = "connu";
}
%>
vous etes <%= etat %>
</body>
</html>
<%--
Created by IntelliJ IDEA.
User: michael
Date: 19/02/2020
Time: 15:35
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>$Title$</title>
</head>
<body>
<form methode="POST" action="affiche.jsp">
Nom :
<input type="text" name="nom">
<br />
Mot de passe :
<input type="text" name="pass">
<br />
<input type="submit" name="ok" value="Envoyer">
</form>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/web" relative="/" />
</webroots>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Tomcat 9.0.311" level="application_server_libraries" />
</component>
</module>
\ No newline at end of file
package metier;
public class Login {
//attributs d'instance
private String nom = "";
private String password = "";
//GETTER SETTER
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
//regle metier
public boolean isConnu(){
return (nom.equals("michael") && password.equals("tiger"));
}
//constructeur
public Login() {
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
</web-app>
\ No newline at end of file
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<meta http-equiv="Refresh" content=""0; URL="pages/login.jsp"/>
</head>
</html>
<%--
Created by IntelliJ IDEA.
User: michael
Date: 19/02/2020
Time: 16:07
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
</body>
</html>
<%--
Created by IntelliJ IDEA.
User: michael
Date: 19/02/2020
Time: 16:04
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
</body>
</html>
-- creation des tables
drop table if exists RETRAIT;
drop table if exists MOUVEMENT;
drop table if exists CARTE;
drop table if exists COMPTE;
drop table if exists CLIENT;
create table CLIENT(
id INT NOT NULL AUTO_INCREMENT,
nom varchar(20) not null,
prenom varchar(20) not null,
adresse varchar(20) not null,
constraint PK_CLIENT primary key (id) ,
constraint UK_CLIENT_NOM_PRENOM UNIQUE (nom, prenom)
)engine=INNODB AUTO_INCREMENT=3 ;
LOCK TABLES CLIENT WRITE;
INSERT INTO CLIENT VALUES
(1,'GATOR','NATHALIE','LILLE'),
(2,'AFEUX','PIERRE','LENS')
;
UNLOCK TABLES;
create table COMPTE(
id INT NOT NULL AUTO_INCREMENT,
numero VARCHAR(10) not null,
titulaire INT NOT NULL,
date_ouverture DATE NOT NULL ,
plafond REAL DEFAULT 0.0,
bloque CHAR(3) DEFAULT 'non',
solde REAL NOT NULL,
constraint PK_COMPTE primary key (id),
constraint UK_COMPTE_NUM UNIQUE (numero),
constraint FK_COMPTE_T FOREIGN KEY (titulaire) references CLIENT(id)
)engine=INNODB AUTO_INCREMENT=5;
LOCK TABLES COMPTE WRITE;
INSERT INTO COMPTE VALUES
(1,'1234',1,current_date,1000.0,'non',200.0),
(2,'1235',1,current_date,0.0,'non',100.0),
(3,'1236',2,current_date,1500.0,'non',300.0),
(4,'1237',1,current_date,0.0,'non',100.0)
;
UNLOCK TABLES;
create table MOUVEMENT(
id INT NOT NULL AUTO_INCREMENT,
id_compte INT not null,
date_operation TIMESTAMP NOT NULL,
montant REAL NOT NULL,
nature CHAR(2),
constraint PK_MOUVEMENT primary key (id),
constraint FK_MOUVEMENT_IDC foreign key (id_compte) references COMPTE(id)
)engine=INNODB AUTO_INCREMENT=4;
LOCK TABLES MOUVEMENT WRITE;
INSERT INTO MOUVEMENT VALUES
(1,1, current_timestamp, 60.0, 'CR'),
(2,3, current_timestamp, 60.0, 'DB'),
(3,3, current_timestamp, 100.0, 'CB')
;
UNLOCK TABLES;
create table CARTE(
id INT NOT NULL AUTO_INCREMENT,
numero varchar(40) not null,
id_compte INT not null,
date_expiration date not null,
codesecret CHAR(4) not null,
bloque char(3) DEFAULT 'non',
nb_essai INT DEFAULT 0,
constraint PK_CARTE primary key (id) ,
constraint UK_CARTE_NUM UNIQUE (numero) ,
constraint FK_CARTE_IDC foreign key (id_compte) references COMPTE(id)
)engine=INNODB AUTO_INCREMENT=3;
LOCK TABLES CARTE WRITE;
INSERT INTO CARTE VALUES
(1,'GATORCB01',1,'2021-05-07','1234','non',0),
(2,'AFEUXCB01',3,'2019-05-06','5678','non',0)
;
UNLOCK TABLES;
create table RETRAIT(
id INT NOT NULL AUTO_INCREMENT,
id_carte INT NOT NULL ,
date_retrait TIMESTAMP not null,
adresseGAB varchar(20) not null,
montant REAL not null,
etat VARCHAR(10) not null,
id_mouvement INT ,
constraint PK_RETRAIT primary key (id),
constraint FK_RETRAIT_CART foreign key (id_carte) references CARTE(id),
constraint FK_RETRAIT_MOUV foreign key (id_mouvement) references MOUVEMENT(id)
)engine=INNODB AUTO_INCREMENT=2;
LOCK TABLES RETRAIT WRITE;
INSERT INTO RETRAIT VALUES
(1, 2,current_timestamp, 'BP LILLE', 100.0, 'SUCCES',3)
;
UNLOCK TABLES;
package dto;
public class CarteDTO {
}
package dto;
public class ClientDTO {
private int id;
private String nom;
private String prenom;
private String adresse;
}
package dto;
import java.io.Serializable;
import java.sql.Date;
public class CompteDTO implements Serializable {
//numero de version
private static final long serialVersionUID = 1L;
//attributs d'instance pertinents
private int id;
private String numero;
private int idtitulaire;
private String nomPrenomTitulaire;
private Date dateOuverture;
private double plafond;
private String bloque;
private double solde;
//----------------------- G E T T E R S E T T E R -----------------------------
public int getId() {
return id;
}
public String getNumero() {
return numero;
}
private void setNumero(String numero) {
this.numero = numero;
}
public int getIdtitulaire() {
return idtitulaire;
}
private void setIdtitulaire(int idtitulaire) {
this.idtitulaire = idtitulaire;
}
public String getNomPrenomTitulaire() {
return nomPrenomTitulaire;
}
private void setNomPrenomTitulaire(String nomPrenomTitulaire) {
this.nomPrenomTitulaire = nomPrenomTitulaire;
}
public Date getDateOuverture() {
return dateOuverture;
}
private void setDateOuverture(Date dateOuverture) {
this.dateOuverture = dateOuverture;
}
public double getPlafond() {
return plafond;
}
private void setPlafond(double plafond) {
this.plafond = plafond;
}
public String getBloque() {
return bloque;
}
private void setBloque(String bloque) {
this.bloque = bloque;
}
public double getSolde() {
return solde;
}
private void setSolde(double solde) {
this.solde = solde;
}
//-------------------------------- C O N S T R U C T E U R --------------------------------
public CompteDTO(int id, String numero, int idtitulaire, String nomPrenomTitulaire, Date dateOuverture,
double plafond, String bloque, double solde) {
this.id = id;
this.numero = numero;
this.idtitulaire = idtitulaire;
this.nomPrenomTitulaire = nomPrenomTitulaire;
this.dateOuverture = dateOuverture;
this.plafond = plafond;
this.bloque = bloque;
this.solde = solde;
}
//tostring
@Override
public String toString() {
return "CompteDTO{" +
"id=" + id +
", numero='" + numero + '\'' +
", idtitulaire=" + idtitulaire +
", nomPrenomTitulaire='" + nomPrenomTitulaire + '\'' +
", dateOuverture=" + dateOuverture +
", plafond=" + plafond +
", bloque='" + bloque + '\'' +
", solde=" + solde +
'}';
}
}
package dto;
public class MouvementDTO {
}
package dto;
public class RetraitDTO {
}
package exception;
public class ExceptionMetier extends Exception{
public ExceptionMetier(){
super();
}
public ExceptionMetier(String message){
super(message);
}
}
package metier;
import dto.CompteDTO;
import exception.ExceptionMetier;
import java.util.*;
public interface IPicsouDAO {
//gestion des comptes
List<CompteDTO> findCompteByClient(int idClient);
CompteDTO findCompteById(int idCompte) throws ExceptionMetier;
//exception du pauvre : renvoyer un status
void credit(int idCompte, double montant) throws ExceptionMetier;
void debit(int idCompte, double montant) throws ExceptionMetier;
void transfert(int idCompteOrigine, int idCompteDestination, double montant) throws ExceptionMetier;
void retrait(int iCarte, String code, double montant, String adr) throws ExceptionMetier;
}
This diff is collapsed.
package service;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ConnectPicsou {
//url de connection
private final static String URL = "jdbc:mysql://localhost:3306/picsou";
//utilisatuer de connection
private final static String USER = "michael";
//mot de passe de connection
private final static String PW = "mdppopmichael";
//SINGLETON precoce ou lazzy ici precoce il s'execute automatiquement
private static Connection INSTANCE;
// initialisateur si singleton precoce un bloc static permet d'initialiser les variables de classes
static{
try{
INSTANCE = DriverManager.getConnection(URL,USER,PW);
}catch(SQLException e){
e.printStackTrace();
}
}
//constructeur privé pour singleton lazzy il faudra l'exectuer
/*private ConnectPicsou() {
try{
INSTANCE = DriverManager.getConnection(URL,USER,PW);
}catch(SQLException e){
e.printStackTrace();
}
}*/
public static Connection getInstance(){
//si singleton lazzy a ajouter
/*if (INSTANCE == null){
new ConnectPicsou();
}*/
return INSTANCE;
}
public static void main(String[] args) {
ConnectPicsou.getInstance();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
</web-app>
\ No newline at end of file
<%--
Created by IntelliJ IDEA.
User: michael
Date: 19/02/2020
Time: 12:40
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>$Title$</title>
</head>
<body>
$END$
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="web" name="Web">
<configuration>
<descriptors>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/web" relative="/" />
</webroots>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
......@@ -7,6 +19,6 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="mysql-connector-java-5.1.6-bin" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Tomcat 9.0.31" level="application_server_libraries" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
</web-app>
\ No newline at end of file
<%--
Created by IntelliJ IDEA.
User: michael
Date: 19/02/2020
Time: 12:40
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>$Title$</title>
</head>
<body>
$END$
</body>
</html>