nomCombiner
This commit is contained in:
parent
038e9182df
commit
e8da463444
2 changed files with 29 additions and 7 deletions
|
@ -34,20 +34,36 @@ public class GestionnaireHistorique {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private String combiner(String id1, String id2) {
|
||||||
|
|
||||||
|
if (id1.compareTo(id2) >= 0) {
|
||||||
|
return id1 + "___" + id2;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return id2 + "___" + id1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void recuperer(String id1, String id2) {
|
public void recuperer(String id1, String id2) {
|
||||||
|
|
||||||
|
String id = combiner(id1, id2);
|
||||||
|
|
||||||
Statement st;
|
Statement st;
|
||||||
int rs1;
|
int rs1;
|
||||||
ResultSet rs2;
|
ResultSet rs2;
|
||||||
|
|
||||||
String query1 =
|
String query1 =
|
||||||
"CREATE TABLE IF NOT EXISTS " + (id1+id2)
|
"CREATE TABLE IF NOT EXISTS " + id
|
||||||
+ "(id INT NOT NULL AUTO_INCREMENT,"
|
+ "(id INT NOT NULL AUTO_INCREMENT,"
|
||||||
+ "expediteur VARCHAR(50),"
|
+ "expediteur VARCHAR(50),"
|
||||||
+ "msg VARCHAR(70),"
|
+ "msg VARCHAR(70),"
|
||||||
+ "PRIMARY KEY (id) );";
|
+ "PRIMARY KEY (id) );";
|
||||||
|
|
||||||
String query2 = "SELECT * FROM " + (id1+id2)
|
String query2 = "SELECT * FROM " + id
|
||||||
+ " ORDRE BY id;";
|
+ " ORDRE BY id;";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -80,11 +96,14 @@ public class GestionnaireHistorique {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void ajouter(String idCombine, String expediteur, String msg) {
|
public void ajouter(String id1, String id2, String expediteur, String msg) {
|
||||||
|
|
||||||
|
String id = combiner(id1, id2);
|
||||||
|
|
||||||
Statement st;
|
Statement st;
|
||||||
int rs;
|
int rs;
|
||||||
|
|
||||||
String query = "INSERT INTO " + idCombine
|
String query = "INSERT INTO " + id
|
||||||
+ "(expediteur, msg) VALUES (" + expediteur + ", " + msg + ");";
|
+ "(expediteur, msg) VALUES (" + expediteur + ", " + msg + ");";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -58,9 +58,6 @@ public class TraitementCmdListe implements Runnable{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//mise à jour des graphismes
|
|
||||||
ListUI.update();
|
|
||||||
|
|
||||||
System.out.println("libéré");
|
System.out.println("libéré");
|
||||||
semaphore.release();
|
semaphore.release();
|
||||||
|
|
||||||
|
@ -112,6 +109,9 @@ public class TraitementCmdListe implements Runnable{
|
||||||
listeUtilisateur.add(new TypeListeUtilisateur(id, nom, ip));
|
listeUtilisateur.add(new TypeListeUtilisateur(id, nom, ip));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//mise à jour des graphismes
|
||||||
|
ListUI.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,5 +125,8 @@ public class TraitementCmdListe implements Runnable{
|
||||||
listeUtilisateur.remove(i);
|
listeUtilisateur.remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//mise à jour des graphismes
|
||||||
|
ListUI.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue