Compare commits
10 commits
master
...
sprint1_v2
Author | SHA1 | Date | |
---|---|---|---|
cb14209e59 | |||
3fda4f07ff | |||
12fbf1601f | |||
b897e4f6a9 | |||
676118c827 | |||
ac22db6ead | |||
277669320e | |||
963e9d680e | |||
fff750c96f | |||
980d4a00f3 |
13 changed files with 212 additions and 0 deletions
8
fichiers_sql/Requests.sql
Normal file
8
fichiers_sql/Requests.sql
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
CREATE TABLE Requests (
|
||||||
|
request_id INT AUTO_INCREMENT NOT NULL,
|
||||||
|
title VARCHAR(30) NOT NULL,
|
||||||
|
content VARCHAR(500) NOT NULL,
|
||||||
|
user_id INT;
|
||||||
|
PRIMARY KEY (request_id)
|
||||||
|
FOREIGN KEY (user_id) REFERENCES Users(user_id)
|
||||||
|
);
|
15
fichiers_sql/Users.sql
Normal file
15
fichiers_sql/Users.sql
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
CREATE TABLE Users (
|
||||||
|
user_id INT AUTO_INCREMENT NOT NULL,
|
||||||
|
nom VARCHAR(100) NOT NULL,
|
||||||
|
user_role VARCHAR(20) NOT NULL,
|
||||||
|
PRIMARY KEY (user_id)
|
||||||
|
CHECK (user_role IN ("DEMANDEUR", "BENEVOLE", "VALIDATEUR")) /*pour eviter que le role soit n'importe quoi*/
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO user (nom, user_role) VALUES ("Tom Cruise", "DEMANDEUR");
|
||||||
|
INSERT INTO user (nom, user_role) VALUES ("Omar Sy", "DEMANDEUR");
|
||||||
|
INSERT INTO user (nom, user_role) VALUES ("Emma Stone", "DEMANDEUR");
|
||||||
|
INSERT INTO user (nom, user_role) VALUES ("Margot Robbie", "BENEVOLE");
|
||||||
|
INSERT INTO user (nom, user_role) VALUES ("Vincent Cassel", "BENEVOLE");
|
||||||
|
INSERT INTO user (nom, user_role) VALUES ("Michael Jackson", "BENEVOLE");
|
||||||
|
INSERT INTO user (nom, user_role) VALUES ("Staff_Purpan", "VALIDATEUR");
|
40
projet_maven/.classpath
Normal file
40
projet_maven/.classpath
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-23">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
</classpath>
|
23
projet_maven/.project
Normal file
23
projet_maven/.project
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>ProjetPDLA</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
8
projet_maven/.settings/org.eclipse.jdt.core.prefs
Normal file
8
projet_maven/.settings/org.eclipse.jdt.core.prefs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=23
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=23
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.release=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=23
|
4
projet_maven/.settings/org.eclipse.m2e.core.prefs
Normal file
4
projet_maven/.settings/org.eclipse.m2e.core.prefs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=true
|
||||||
|
version=1
|
2
projet_maven/codebdd.txt
Normal file
2
projet_maven/codebdd.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
cmd: mysql -h srv-bdens.insa-toulouse.fr --port=3306 -u projet_gei_023 -p projet_gei_023
|
||||||
|
mdp: ohQu4ood
|
55
projet_maven/pom.xml
Normal file
55
projet_maven/pom.xml
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>fr.insa.maven.pdla</groupId>
|
||||||
|
<artifactId>ProjetPDLA</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>23</maven.compiler.source>
|
||||||
|
<maven.compiler.target>23</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/junit/junit -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.13.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.postgresql</groupId>
|
||||||
|
<artifactId>postgresql</artifactId>
|
||||||
|
<version>42.7.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.mysql/mysql-connector-j -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
<version>9.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<addClasspath>true</addClasspath>
|
||||||
|
<mainClass>fr.pdla.demo.HelloClass</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
30
projet_maven/src/main/java/InsertUser.java
Normal file
30
projet_maven/src/main/java/InsertUser.java
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
public class InsertUser {
|
||||||
|
|
||||||
|
// /!\ PROTOTYPE A MODIFIER SUIVANT FORMAT FINAL DE LA BDD /!\
|
||||||
|
// fonction qui insere l'user dans la bdd insa
|
||||||
|
public static void insertUser(String nom, String user_role) {
|
||||||
|
// pour se connecter a la bdd
|
||||||
|
String url = "jdbc:mysql://srv-bdens.insa-toulouse.fr:3306/projet_gei_023"; // url sur moodle
|
||||||
|
String user = "projet_gei_023"; // login
|
||||||
|
String password = "ohQu4ood"; // mdp sur liste binomes
|
||||||
|
|
||||||
|
try (Connection connection = DriverManager.getConnection(url, user, password)) {
|
||||||
|
|
||||||
|
Statement stmt = connection.createStatement();
|
||||||
|
|
||||||
|
// on cree requete SQL avec entrees user
|
||||||
|
String insertQuery = "INSERT INTO User(nom, user_role) VALUES ('" + nom + "', '" + user_role + "')";
|
||||||
|
|
||||||
|
// on fait la requete
|
||||||
|
stmt.executeUpdate(insertQuery);
|
||||||
|
System.out.println("Ligne insérée avec succès.");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.err.println("Echec de l'insertion : " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
projet_maven/src/main/java/Main.java
Normal file
27
projet_maven/src/main/java/Main.java
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
//on active le scanner pour recuperer les entrees user
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// on demande nom et role de l'user
|
||||||
|
System.out.print("Entrez votre nom d'utilisateur (100 caractères max): "); // modifier le nb de caracteres max suivant bdd
|
||||||
|
String nom = scanner.nextLine();
|
||||||
|
|
||||||
|
System.out.print("Entrez votre rôle (DEMANDEUR, BENEVOLE, VALIDATEUR) : ");
|
||||||
|
String user_role = scanner.nextLine();
|
||||||
|
|
||||||
|
// on insere dans la table user dans la base de donnees insa
|
||||||
|
InsertUser.insertUser(nom, user_role);
|
||||||
|
} finally {
|
||||||
|
//on libere le scanner meme si l'insertion a echoue (d'ou le bloc try/finally)
|
||||||
|
scanner.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//code a changer parce que s'il y a une erreur on doit relancer la connection à chaque fois au lieu de juste redemander
|
BIN
projet_maven/target/ProjetPDLA-0.0.1-SNAPSHOT.jar
Normal file
BIN
projet_maven/target/ProjetPDLA-0.0.1-SNAPSHOT.jar
Normal file
Binary file not shown.
BIN
projet_maven/target/classes/InsertUser.class
Normal file
BIN
projet_maven/target/classes/InsertUser.class
Normal file
Binary file not shown.
BIN
projet_maven/target/classes/Main.class
Normal file
BIN
projet_maven/target/classes/Main.class
Normal file
Binary file not shown.
Loading…
Reference in a new issue