fin chap9
This commit is contained in:
parent
2fe537045d
commit
d7334787cd
@ -1,90 +1,90 @@
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=true
|
||||
annotation.processing.processors.list=
|
||||
annotation.processing.run.all.processors=true
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
build.classes.dir=${build.web.dir}/WEB-INF/classes
|
||||
build.classes.excludes=**/*.java,**/*.form
|
||||
build.dir=build
|
||||
build.generated.dir=${build.dir}/generated
|
||||
build.generated.sources.dir=${build.dir}/generated-sources
|
||||
build.test.classes.dir=${build.dir}/test/classes
|
||||
build.test.results.dir=${build.dir}/test/results
|
||||
build.web.dir=${build.dir}/web
|
||||
build.web.excludes=${build.classes.excludes}
|
||||
client.urlPart=
|
||||
compile.jsps=false
|
||||
conf.dir=${source.root}/conf
|
||||
debug.classpath=${build.classes.dir}:${javac.classpath}
|
||||
debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
display.browser=true
|
||||
# Files to be excluded from distribution war
|
||||
dist.archive.excludes=
|
||||
dist.dir=dist
|
||||
dist.ear.war=${dist.dir}/${war.ear.name}
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
dist.war=${dist.dir}/${war.name}
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar=../../../../Users/sio/Downloads/jakarta.servlet.jsp.jstl-2.0.0.jar
|
||||
file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar=../../../../Users/sio/Downloads/jakarta.servlet.jsp.jstl-api-2.0.0.jar
|
||||
file.reference.mysql-connector-java-8.0.23.jar=../../../../Users/sio/Downloads/mysql-connector-java-8.0.23.jar
|
||||
file.reference.mysql-connector-java-8.0.23.jar-1=../Drivers/mysql-connector-java-8.0.23.jar
|
||||
includes=**
|
||||
j2ee.compile.on.save=true
|
||||
j2ee.copy.static.files.on.save=true
|
||||
j2ee.deploy.on.save=true
|
||||
j2ee.platform=10-web
|
||||
j2ee.platform.classpath=${j2ee.server.home}/bin/tomcat-juli.jar:${j2ee.server.home}/lib/annotations-api.jar:${j2ee.server.home}/lib/catalina-ant.jar:${j2ee.server.home}/lib/catalina-ha.jar:${j2ee.server.home}/lib/catalina-ssi.jar:${j2ee.server.home}/lib/catalina-storeconfig.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/ecj-4.27.jar:${j2ee.server.home}/lib/el-api.jar:${j2ee.server.home}/lib/jakartaee-migration-1.0.8-shaded.jar:${j2ee.server.home}/lib/jasper-el.jar:${j2ee.server.home}/lib/jasper.jar:${j2ee.server.home}/lib/jaspic-api.jar:${j2ee.server.home}/lib/jsp-api.jar:${j2ee.server.home}/lib/servlet-api.jar:${j2ee.server.home}/lib/tomcat-api.jar:${j2ee.server.home}/lib/tomcat-coyote-ffm.jar:${j2ee.server.home}/lib/tomcat-coyote.jar:${j2ee.server.home}/lib/tomcat-dbcp.jar:${j2ee.server.home}/lib/tomcat-i18n-cs.jar:${j2ee.server.home}/lib/tomcat-i18n-de.jar:${j2ee.server.home}/lib/tomcat-i18n-es.jar:${j2ee.server.home}/lib/tomcat-i18n-fr.jar:${j2ee.server.home}/lib/tomcat-i18n-ja.jar:${j2ee.server.home}/lib/tomcat-i18n-ko.jar:${j2ee.server.home}/lib/tomcat-i18n-pt-BR.jar:${j2ee.server.home}/lib/tomcat-i18n-ru.jar:${j2ee.server.home}/lib/tomcat-i18n-zh-CN.jar:${j2ee.server.home}/lib/tomcat-jdbc.jar:${j2ee.server.home}/lib/tomcat-jni.jar:${j2ee.server.home}/lib/tomcat-util-scan.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat-websocket.jar:${j2ee.server.home}/lib/websocket-api.jar:${j2ee.server.home}/lib/websocket-client-api.jar
|
||||
j2ee.server.type=Tomcat
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar}:\
|
||||
${file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar}:\
|
||||
${file.reference.mysql-connector-java-8.0.23.jar}:\
|
||||
${file.reference.mysql-connector-java-8.0.23.jar-1}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.debug=true
|
||||
javac.deprecation=false
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=21
|
||||
javac.target=21
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
javac.test.processorpath=\
|
||||
${javac.test.classpath}
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=${source.encoding}
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.preview=true
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
lib.dir=${web.docbase.dir}/WEB-INF/lib
|
||||
persistence.xml.dir=${conf.dir}
|
||||
platform.active=default_platform
|
||||
resource.dir=setup
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
${build.test.classes.dir}
|
||||
# Space-separated list of JVM arguments used when running a class with a main method or a unit test
|
||||
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value):
|
||||
runmain.jvmargs=
|
||||
source.encoding=UTF-8
|
||||
source.root=src
|
||||
src.dir=${source.root}/java
|
||||
test.src.dir=test
|
||||
war.content.additional=
|
||||
war.ear.name=${war.name}
|
||||
war.name=Test2JakartaV9.war
|
||||
web.docbase.dir=web
|
||||
webinf.dir=web/WEB-INF
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=true
|
||||
annotation.processing.processors.list=
|
||||
annotation.processing.run.all.processors=true
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
build.classes.dir=${build.web.dir}/WEB-INF/classes
|
||||
build.classes.excludes=**/*.java,**/*.form
|
||||
build.dir=build
|
||||
build.generated.dir=${build.dir}/generated
|
||||
build.generated.sources.dir=${build.dir}/generated-sources
|
||||
build.test.classes.dir=${build.dir}/test/classes
|
||||
build.test.results.dir=${build.dir}/test/results
|
||||
build.web.dir=${build.dir}/web
|
||||
build.web.excludes=${build.classes.excludes}
|
||||
client.urlPart=
|
||||
compile.jsps=false
|
||||
conf.dir=${source.root}/conf
|
||||
debug.classpath=${build.classes.dir}:${javac.classpath}
|
||||
debug.test.classpath=\
|
||||
${run.test.classpath}
|
||||
display.browser=true
|
||||
# Files to be excluded from distribution war
|
||||
dist.archive.excludes=
|
||||
dist.dir=dist
|
||||
dist.ear.war=${dist.dir}/${war.ear.name}
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
dist.war=${dist.dir}/${war.name}
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar=../../../../Users/sio/Downloads/jakarta.servlet.jsp.jstl-2.0.0.jar
|
||||
file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar=../../../../Users/sio/Downloads/jakarta.servlet.jsp.jstl-api-2.0.0.jar
|
||||
file.reference.mysql-connector-java-8.0.23.jar=../../../../Users/sio/Downloads/mysql-connector-java-8.0.23.jar
|
||||
file.reference.mysql-connector-java-8.0.23.jar-1=../Drivers/mysql-connector-java-8.0.23.jar
|
||||
includes=**
|
||||
j2ee.compile.on.save=true
|
||||
j2ee.copy.static.files.on.save=true
|
||||
j2ee.deploy.on.save=true
|
||||
j2ee.platform=10-web
|
||||
j2ee.platform.classpath=${j2ee.server.home}/bin/tomcat-juli.jar:${j2ee.server.home}/lib/annotations-api.jar:${j2ee.server.home}/lib/catalina-ant.jar:${j2ee.server.home}/lib/catalina-ha.jar:${j2ee.server.home}/lib/catalina-ssi.jar:${j2ee.server.home}/lib/catalina-storeconfig.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/ecj-4.27.jar:${j2ee.server.home}/lib/el-api.jar:${j2ee.server.home}/lib/jakartaee-migration-1.0.8-shaded.jar:${j2ee.server.home}/lib/jasper-el.jar:${j2ee.server.home}/lib/jasper.jar:${j2ee.server.home}/lib/jaspic-api.jar:${j2ee.server.home}/lib/jsp-api.jar:${j2ee.server.home}/lib/mysql-connector-java-8.0.23.jar:${j2ee.server.home}/lib/servlet-api.jar:${j2ee.server.home}/lib/tomcat-api.jar:${j2ee.server.home}/lib/tomcat-coyote-ffm.jar:${j2ee.server.home}/lib/tomcat-coyote.jar:${j2ee.server.home}/lib/tomcat-dbcp.jar:${j2ee.server.home}/lib/tomcat-i18n-cs.jar:${j2ee.server.home}/lib/tomcat-i18n-de.jar:${j2ee.server.home}/lib/tomcat-i18n-es.jar:${j2ee.server.home}/lib/tomcat-i18n-fr.jar:${j2ee.server.home}/lib/tomcat-i18n-ja.jar:${j2ee.server.home}/lib/tomcat-i18n-ko.jar:${j2ee.server.home}/lib/tomcat-i18n-pt-BR.jar:${j2ee.server.home}/lib/tomcat-i18n-ru.jar:${j2ee.server.home}/lib/tomcat-i18n-zh-CN.jar:${j2ee.server.home}/lib/tomcat-jdbc.jar:${j2ee.server.home}/lib/tomcat-jni.jar:${j2ee.server.home}/lib/tomcat-util-scan.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat-websocket.jar:${j2ee.server.home}/lib/websocket-api.jar:${j2ee.server.home}/lib/websocket-client-api.jar
|
||||
j2ee.server.type=Tomcat
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.jakarta.servlet.jsp.jstl-2.0.0.jar}:\
|
||||
${file.reference.jakarta.servlet.jsp.jstl-api-2.0.0.jar}:\
|
||||
${file.reference.mysql-connector-java-8.0.23.jar}:\
|
||||
${file.reference.mysql-connector-java-8.0.23.jar-1}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.debug=true
|
||||
javac.deprecation=false
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=21
|
||||
javac.target=21
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
javac.test.processorpath=\
|
||||
${javac.test.classpath}
|
||||
javadoc.additionalparam=
|
||||
javadoc.author=false
|
||||
javadoc.encoding=${source.encoding}
|
||||
javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.preview=true
|
||||
javadoc.private=false
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
lib.dir=${web.docbase.dir}/WEB-INF/lib
|
||||
persistence.xml.dir=${conf.dir}
|
||||
platform.active=default_platform
|
||||
resource.dir=setup
|
||||
run.test.classpath=\
|
||||
${javac.test.classpath}:\
|
||||
${build.test.classes.dir}
|
||||
# Space-separated list of JVM arguments used when running a class with a main method or a unit test
|
||||
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value):
|
||||
runmain.jvmargs=
|
||||
source.encoding=UTF-8
|
||||
source.root=src
|
||||
src.dir=${source.root}/java
|
||||
test.src.dir=test
|
||||
war.content.additional=
|
||||
war.ear.name=${war.name}
|
||||
war.name=Test2JakartaV9.war
|
||||
web.docbase.dir=web
|
||||
webinf.dir=web/WEB-INF
|
||||
|
@ -1,85 +1,85 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package bdd;
|
||||
|
||||
import java.sql.Statement;
|
||||
import javabeans.Client;
|
||||
import java.util.ArrayList;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
/**
|
||||
*
|
||||
* @author sio
|
||||
*/
|
||||
public class ClientMySQL {
|
||||
/*Connexion MV serveurBD lycée
|
||||
private final Connection laConnection = Connexion.getConnect("10.121.38.165", "bdclient", "adminBDClient", "mdpBDClient");*/
|
||||
|
||||
/*Connexion wampserver
|
||||
private final Connection laConnection = Connexion.getConnect("localhost", "bdclient", "adminBDClient", "mdpBDClient");*/
|
||||
|
||||
//connexion MV serveurBD maison
|
||||
private final Connection laConnection = Connexion.getConnect("192.168.1.21", "bdclient", "adminBDClient", "mdpBDClient");
|
||||
|
||||
public int create(Client c){
|
||||
int id=-1;
|
||||
try{
|
||||
Statement stmt = laConnection.createStatement();
|
||||
int status= stmt.executeUpdate(
|
||||
" INSERT INTO client (nom, prenom, mail) VALUES ('"
|
||||
+c.getNom() +"','"
|
||||
+c.getPrenom() +"','"
|
||||
+c.getMail() +"');",
|
||||
Statement.RETURN_GENERATED_KEYS);
|
||||
if (status>0)
|
||||
{
|
||||
ResultSet result=stmt.getGeneratedKeys();
|
||||
if (result.first()){
|
||||
id = result.getInt(1);
|
||||
}
|
||||
}
|
||||
stmt.close();
|
||||
}catch (SQLException ex){
|
||||
System.out.println("SQLException : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public Client read(int num){
|
||||
return null;
|
||||
}
|
||||
|
||||
public void update(int num){
|
||||
|
||||
}
|
||||
|
||||
public void delete(int num){
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<String> readAll(){
|
||||
ArrayList <String> lesClients = new ArrayList<>();
|
||||
try{
|
||||
Statement stmt = laConnection.createStatement();
|
||||
ResultSet resultQ = null;
|
||||
resultQ = stmt.executeQuery("SELECT * FROM client");
|
||||
while(resultQ.next()){
|
||||
String resultat = resultQ.getString("nom") + " " + resultQ.getString("prenom");
|
||||
lesClients.add(resultat);
|
||||
}
|
||||
resultQ.close();
|
||||
stmt.close();
|
||||
}catch (SQLException ex){
|
||||
System.out.println("SQLException : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
return lesClients;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package bdd;
|
||||
|
||||
import java.sql.Statement;
|
||||
import javabeans.Client;
|
||||
import java.util.ArrayList;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
/**
|
||||
*
|
||||
* @author sio
|
||||
*/
|
||||
public class ClientMySQL {
|
||||
//Connexion MV serveurBD lycée
|
||||
private final Connection laConnection = Connexion.getConnect("10.121.38.106", "bdclient", "adminBDClient", "mdpBDClient");
|
||||
|
||||
/*Connexion wampserver
|
||||
private final Connection laConnection = Connexion.getConnect("localhost", "bdclient", "adminBDClient", "mdpBDClient");*/
|
||||
|
||||
//connexion MV serveurBD maison
|
||||
//private final Connection laConnection = Connexion.getConnect("192.168.1.21", "bdclient", "adminBDClient", "mdpBDClient");
|
||||
|
||||
public int create(Client c){
|
||||
int id=-1;
|
||||
try{
|
||||
Statement stmt = laConnection.createStatement();
|
||||
int status= stmt.executeUpdate(
|
||||
" INSERT INTO client (nom, prenom, mail) VALUES ('"
|
||||
+c.getNom() +"','"
|
||||
+c.getPrenom() +"','"
|
||||
+c.getMail() +"');",
|
||||
Statement.RETURN_GENERATED_KEYS);
|
||||
if (status>0)
|
||||
{
|
||||
ResultSet result=stmt.getGeneratedKeys();
|
||||
if (result.first()){
|
||||
id = result.getInt(1);
|
||||
}
|
||||
}
|
||||
stmt.close();
|
||||
}catch (SQLException ex){
|
||||
System.out.println("SQLException : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public Client read(int num){
|
||||
return null;
|
||||
}
|
||||
|
||||
public void update(int num){
|
||||
|
||||
}
|
||||
|
||||
public void delete(int num){
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<String> readAll(){
|
||||
ArrayList <String> lesClients = new ArrayList<>();
|
||||
try{
|
||||
Statement stmt = laConnection.createStatement();
|
||||
ResultSet resultQ = null;
|
||||
resultQ = stmt.executeQuery("SELECT * FROM client");
|
||||
while(resultQ.next()){
|
||||
String resultat = resultQ.getString("nom") + " " + resultQ.getString("prenom");
|
||||
lesClients.add(resultat);
|
||||
}
|
||||
resultQ.close();
|
||||
stmt.close();
|
||||
}catch (SQLException ex){
|
||||
System.out.println("SQLException : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
return lesClients;
|
||||
}
|
||||
}
|
||||
|
@ -1,83 +1,83 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package bdd;
|
||||
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javabeans.User;
|
||||
/**
|
||||
*
|
||||
* @author sio
|
||||
*/
|
||||
public class SalarieMySQL {
|
||||
/*Connexion MV serveurBD lycée
|
||||
private final Connection laConnection = Connexion.getConnect("10.121.38.165", "bdclient", "adminBDClient", "mdpBDClient");*/
|
||||
|
||||
/*Connexion wampserver
|
||||
private final Connection laConnection = Connexion.getConnect("localhost", "bdclient", "adminBDClient", "mdpBDClient");*/
|
||||
|
||||
//connexion MV serveurBD maison
|
||||
private final Connection laConnection = Connexion.getConnect("192.168.1.21", "bdclient", "adminBDClient", "mdpBDClient");
|
||||
|
||||
|
||||
|
||||
public ArrayList<User> readAll(){
|
||||
User leSalarie=new User("lo","log");
|
||||
ArrayList <User> lesSalaries = new ArrayList<>();
|
||||
try{
|
||||
Statement stmt = laConnection.createStatement();
|
||||
ResultSet resultQ = null;
|
||||
resultQ = stmt.executeQuery("SELECT * FROM salarie");
|
||||
while(resultQ.next()){
|
||||
leSalarie.setLogin(resultQ.getString("login"));
|
||||
leSalarie.setId(resultQ.getInt("idSal"));
|
||||
leSalarie.setMdp(resultQ.getString("mdp"));
|
||||
leSalarie.setRole(resultQ.getBoolean("role"));
|
||||
lesSalaries.add(leSalarie);
|
||||
}
|
||||
resultQ.close();
|
||||
stmt.close();
|
||||
}catch (SQLException ex){
|
||||
System.out.println("SQLException : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
return lesSalaries;
|
||||
}
|
||||
|
||||
public User lireSalarie(String log, String m){
|
||||
User leSalarie=new User();
|
||||
ResultSet resultQ = null;
|
||||
try{
|
||||
|
||||
PreparedStatement prepStmt = null;
|
||||
|
||||
String sql = "SELECT * FROM Salarie WHERE login = ? AND mdp=?";
|
||||
prepStmt = laConnection.prepareStatement(sql); // pré-compilation
|
||||
|
||||
prepStmt.setString(1, log); //le param. 1 est remplacé par "Toto"
|
||||
prepStmt.setString(2,m);
|
||||
resultQ = prepStmt.executeQuery();
|
||||
if (resultQ.first()){
|
||||
leSalarie.setLogin(resultQ.getString("login"));
|
||||
leSalarie.setId(resultQ.getInt("idSal"));
|
||||
leSalarie.setMdp(resultQ.getString("mdp"));
|
||||
leSalarie.setRole(resultQ.getBoolean("role"));
|
||||
}
|
||||
resultQ.close();
|
||||
prepStmt.close();
|
||||
}catch (SQLException ex){
|
||||
System.out.println("SQLException : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
return leSalarie;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package bdd;
|
||||
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import javabeans.User;
|
||||
/**
|
||||
*
|
||||
* @author sio
|
||||
*/
|
||||
public class SalarieMySQL {
|
||||
//Connexion MV serveurBD lycée
|
||||
private final Connection laConnection = Connexion.getConnect("10.121.38.106", "bdclient", "adminBDClient", "mdpBDClient");
|
||||
|
||||
/*Connexion wampserver
|
||||
private final Connection laConnection = Connexion.getConnect("localhost", "bdclient", "adminBDClient", "mdpBDClient");*/
|
||||
|
||||
//connexion MV serveurBD maison
|
||||
// private final Connection laConnection = Connexion.getConnect("192.168.1.21", "bdclient", "adminBDClient", "mdpBDClient");
|
||||
|
||||
|
||||
|
||||
public ArrayList<User> readAll(){
|
||||
User leSalarie=new User("lo","log");
|
||||
ArrayList <User> lesSalaries = new ArrayList<>();
|
||||
try{
|
||||
Statement stmt = laConnection.createStatement();
|
||||
ResultSet resultQ = null;
|
||||
resultQ = stmt.executeQuery("SELECT * FROM salarie");
|
||||
while(resultQ.next()){
|
||||
leSalarie.setLogin(resultQ.getString("login"));
|
||||
leSalarie.setId(resultQ.getInt("idSal"));
|
||||
leSalarie.setMdp(resultQ.getString("mdp"));
|
||||
leSalarie.setRole(resultQ.getBoolean("role"));
|
||||
lesSalaries.add(leSalarie);
|
||||
}
|
||||
resultQ.close();
|
||||
stmt.close();
|
||||
}catch (SQLException ex){
|
||||
System.out.println("SQLException : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
return lesSalaries;
|
||||
}
|
||||
|
||||
public User lireSalarie(String log, String m){
|
||||
User leSalarie=new User();
|
||||
ResultSet resultQ = null;
|
||||
try{
|
||||
|
||||
PreparedStatement prepStmt = null;
|
||||
|
||||
String sql = "SELECT * FROM Salarie WHERE login = ? AND mdp=?";
|
||||
prepStmt = laConnection.prepareStatement(sql); // pré-compilation
|
||||
|
||||
prepStmt.setString(1, log); //le param. 1 est remplacé par "Toto"
|
||||
prepStmt.setString(2,m);
|
||||
resultQ = prepStmt.executeQuery();
|
||||
if (resultQ.first()){
|
||||
leSalarie.setLogin(resultQ.getString("login"));
|
||||
leSalarie.setId(resultQ.getInt("idSal"));
|
||||
leSalarie.setMdp(resultQ.getString("mdp"));
|
||||
leSalarie.setRole(resultQ.getBoolean("role"));
|
||||
}
|
||||
resultQ.close();
|
||||
prepStmt.close();
|
||||
}catch (SQLException ex){
|
||||
System.out.println("SQLException : " + ex.getMessage());
|
||||
System.out.println("SQLState : " + ex.getSQLState());
|
||||
System.out.println("Code erreur : " + ex.getErrorCode());
|
||||
}
|
||||
return leSalarie;
|
||||
}
|
||||
}
|
||||
|
@ -1,93 +1,92 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Servlet.java to edit this template
|
||||
*/
|
||||
package gestionClient;
|
||||
|
||||
import bdd.ClientMySQL;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.annotation.WebServlet;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author famille Thevenot
|
||||
*/
|
||||
@WebServlet(name = "ListeServlet2", urlPatterns = {"/ListeClients"})
|
||||
public class ListeServlet2 extends HttpServlet {
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
try (PrintWriter out = response.getWriter()) {
|
||||
/* TODO output your page here. You may use following sample code. */
|
||||
out.println("<!DOCTYPE html>");
|
||||
out.println("<html>");
|
||||
out.println("<head>");
|
||||
out.println("<title>Servlet ListeServlet2</title>");
|
||||
out.println("</head>");
|
||||
out.println("<body>");
|
||||
out.println("<h1>Servlet ListeServlet2 at " + request.getContextPath() + "</h1>");
|
||||
out.println("</body>");
|
||||
out.println("</html>");
|
||||
}
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
System.out.println("ListeServlet2");
|
||||
ClientMySQL cli = new ClientMySQL();
|
||||
|
||||
|
||||
request.setAttribute("laListe", cli.readAll());
|
||||
getServletContext().getRequestDispatcher("/WEB-INF/listeClientsVue.jsp").forward(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Servlet.java to edit this template
|
||||
*/
|
||||
package gestionClient;
|
||||
|
||||
import bdd.ClientMySQL;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.annotation.WebServlet;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author famille Thevenot
|
||||
*/
|
||||
@WebServlet(name = "ListeServlet2", urlPatterns = {"/ListeClients"})
|
||||
public class ListeServlet2 extends HttpServlet {
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
try (PrintWriter out = response.getWriter()) {
|
||||
/* TODO output your page here. You may use following sample code. */
|
||||
out.println("<!DOCTYPE html>");
|
||||
out.println("<html>");
|
||||
out.println("<head>");
|
||||
out.println("<title>Servlet ListeServlet2</title>");
|
||||
out.println("</head>");
|
||||
out.println("<body>");
|
||||
out.println("<h1>Servlet ListeServlet2 at " + request.getContextPath() + "</h1>");
|
||||
out.println("</body>");
|
||||
out.println("</html>");
|
||||
}
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
System.out.println("ListeServlet2");
|
||||
ClientMySQL cli = new ClientMySQL();
|
||||
//envoyer à la vue la liste des clients
|
||||
request.setAttribute("laListe", cli.readAll());
|
||||
getServletContext().getRequestDispatcher("/WEB-INF/listeClientsVue.jsp").forward(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
processRequest(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
||||
|
@ -1,112 +1,112 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Servlet.java to edit this template
|
||||
*/
|
||||
package gestionClient;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import java.util.ArrayList;
|
||||
import testForms.AuthentifForm;
|
||||
import testForms.NouveauClientForm;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author famille Thevenot
|
||||
*/
|
||||
public class NouveauServlet extends HttpServlet {
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
try (PrintWriter out = response.getWriter()) {
|
||||
/* TODO output your page here. You may use following sample code. */
|
||||
out.println("<!DOCTYPE html>");
|
||||
out.println("<html>");
|
||||
out.println("<head>");
|
||||
out.println("<title>Servlet NouveauServlet</title>");
|
||||
out.println("</head>");
|
||||
out.println("<body>");
|
||||
out.println("<h1>Servlet NouveauServlet at " + request.getContextPath() + "</h1>");
|
||||
out.println("</body>");
|
||||
out.println("</html>");
|
||||
}
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
getServletContext().getRequestDispatcher("/WEB-INF/nouveauClientVue.jsp").forward(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
//processRequest(request, response);
|
||||
//Création de l'objet leControl de type AuthentifForm
|
||||
NouveauClientForm leControle = new NouveauClientForm();
|
||||
//Appel de la méthode controlerAdmin
|
||||
int isNum=leControle.verifierClient(request);
|
||||
//création de 2 attributs de requête (isAdmin et leControle)
|
||||
request.setAttribute("controlForm", leControle);
|
||||
request.setAttribute("isNumAjoute", isNum);
|
||||
//gestion de la liste des clients créés
|
||||
if (isNum != -1) {
|
||||
// Ajout du no du client créé, dans une collection d’entiers stockée en session
|
||||
// 1, Récupération de la session
|
||||
HttpSession maSession = request.getSession();
|
||||
// 2. Récupération de la collection des clients si elle existe, création sinon
|
||||
ArrayList<Integer> lesNouveauxClients = (ArrayList<Integer>) maSession.getAttribute("lesNvxClients");
|
||||
if (lesNouveauxClients == null) {
|
||||
lesNouveauxClients = new ArrayList<>();
|
||||
}
|
||||
// 3. Ajout du no du client créé dans la collection
|
||||
lesNouveauxClients.add(isNum);
|
||||
// 4. Mise à jour de la session
|
||||
maSession.setAttribute("lesNvxClients", lesNouveauxClients); }
|
||||
//Affichage JSP, redirection couche vue
|
||||
getServletContext().getRequestDispatcher("/WEB-INF/nouveauClientVue.jsp").forward(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Servlet.java to edit this template
|
||||
*/
|
||||
package gestionClient;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import java.util.ArrayList;
|
||||
import testForms.AuthentifForm;
|
||||
import testForms.NouveauClientForm;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author famille Thevenot
|
||||
*/
|
||||
public class NouveauServlet extends HttpServlet {
|
||||
|
||||
/**
|
||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||
* methods.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
response.setContentType("text/html;charset=UTF-8");
|
||||
try (PrintWriter out = response.getWriter()) {
|
||||
/* TODO output your page here. You may use following sample code. */
|
||||
out.println("<!DOCTYPE html>");
|
||||
out.println("<html>");
|
||||
out.println("<head>");
|
||||
out.println("<title>Servlet NouveauServlet</title>");
|
||||
out.println("</head>");
|
||||
out.println("<body>");
|
||||
out.println("<h1>Servlet NouveauServlet at " + request.getContextPath() + "</h1>");
|
||||
out.println("</body>");
|
||||
out.println("</html>");
|
||||
}
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
||||
/**
|
||||
* Handles the HTTP <code>GET</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
getServletContext().getRequestDispatcher("/WEB-INF/nouveauClientVue.jsp").forward(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the HTTP <code>POST</code> method.
|
||||
*
|
||||
* @param request servlet request
|
||||
* @param response servlet response
|
||||
* @throws ServletException if a servlet-specific error occurs
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
// 1, Récupération de la session
|
||||
HttpSession maSession = request.getSession();
|
||||
//Création de l'objet leControl de type AuthentifForm
|
||||
NouveauClientForm leControle = new NouveauClientForm();
|
||||
//Appel de la méthode créer le client dans la BD
|
||||
int isNum=leControle.verifierClient(request);
|
||||
//création de 2 attributs de requête (isAdmin et leControle)
|
||||
request.setAttribute("controlForm", leControle);
|
||||
request.setAttribute("isNumAjoute", isNum);
|
||||
//gestion de la liste des clients créés
|
||||
if (isNum != -1) {
|
||||
// Ajout du no du client créé, dans une collection d’entiers stockée en session
|
||||
// 2. Récupération de la collection des clients si elle existe, création sinon
|
||||
ArrayList<Integer> lesNouveauxClients = (ArrayList<Integer>) maSession.getAttribute("lesNvxClients");
|
||||
if (lesNouveauxClients == null) {
|
||||
lesNouveauxClients = new ArrayList<>();
|
||||
}
|
||||
// 3. Ajout du no du client créé dans la collection
|
||||
lesNouveauxClients.add(isNum);
|
||||
// 4. Mise à jour de la session
|
||||
maSession.setAttribute("lesNvxClients", lesNouveauxClients);
|
||||
}
|
||||
//Affichage JSP, redirection couche vue
|
||||
getServletContext().getRequestDispatcher("/WEB-INF/nouveauClientVue.jsp").forward(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a short description of the servlet.
|
||||
*
|
||||
* @return a String containing servlet description
|
||||
*/
|
||||
@Override
|
||||
public String getServletInfo() {
|
||||
return "Short description";
|
||||
}// </editor-fold>
|
||||
|
||||
}
|
||||
|
@ -13,12 +13,12 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Liste des clients</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%@include file="jspf/enteteClient.jspf" %>
|
||||
<%@include file="jspf/menuClient.jspf" %>
|
||||
<h2>Liste des clients</h2>
|
||||
|
||||
<%--Affichage de la vue--%>
|
||||
<c:out value="${laListe}" default="La liste doit être là" />
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user