Compare commits

..

No commits in common. "a58cd8294c87bc1acf75172b8c65c892b1165784" and "021ed7cec076e856c18fce1dfc7bc22892407674" have entirely different histories.

3 changed files with 19 additions and 22 deletions

View file

@ -52,8 +52,8 @@ public class Controller {
* - notification aux autres utilisateurs actifs * - notification aux autres utilisateurs actifs
* </p> * </p>
*/ */
private Controller(int portUDPsend,int portUDPlistening,int portTCP,Historique histoire) { private Controller(int portUDPsend,int portUDPlistening,int portTCP) {
this.histoire= histoire; this.histoire= new Historique();
InetAddress addIP = null; InetAddress addIP = null;
try try
@ -97,8 +97,7 @@ public class Controller {
* - notification aux autres utilisateurs actifs * - notification aux autres utilisateurs actifs
* </p> * </p>
*/ */
private Controller(int portUDPsend,int portUDPlistening,int portTCP,String pseudo,Historique histoire) { private Controller(int portUDPsend,int portUDPlistening,int portTCP,String pseudo) {
this.histoire=histoire;
InetAddress addIP = null; InetAddress addIP = null;
try try
{ {
@ -362,8 +361,7 @@ public class Controller {
Calendar date1=Calendar.getInstance(); Calendar date1=Calendar.getInstance();
date = new Date(); date = new Date();
date1.setTime(date); date1.setTime(date);
dateString=date1.toString(); dateString=date1.toString();
this.getHistory().saveMessage(getMyUser(), c.getRemoteUser(),message ,dateString );
/* /*
System.out.println(this.getHistory()); System.out.println(this.getHistory());
@ -378,8 +376,8 @@ public class Controller {
//this.getHistory().saveMessage(this.myUser, c.getRemoteUser(),message ,dateString); //this.getHistory().saveMessage(this.myUser, c.getRemoteUser(),message ,dateString);
// Envoie du message (avec la date) // Envoie du message (avec la date)
//DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
out.println(dateString); out.println(dateFormat.format(date));
out.println(message); out.println(message);
} }
@ -492,15 +490,14 @@ public class Controller {
System.out.println("start program"); System.out.println("start program");
Historique histoire=new Historique(); Historique histoire=new Historique();
/** Création des utilisateurs **/ /** Création des utilisateurs **/
// REMOTEUSER_1 - MIKE // REMOTEUSER_1 - MIKE
Controller ctr2 = new Controller(31012,portUDPlistening_remoteUsr2,31022,"Mike",histoire); Controller ctr2 = new Controller(31012,portUDPlistening_remoteUsr2,31022,"Mike");
// REMOTEUSER_2 - ALICE // REMOTEUSER_2 - ALICE
Controller ctr3 = new Controller(31013,portUDPlistening_remoteUsr3,31023,"Alice",histoire); Controller ctr3 = new Controller(31013,portUDPlistening_remoteUsr3,31023,"Alice");
// LOCAL USER // LOCAL USER
Controller ctr1 = new Controller(31011,31001,31021,histoire); Controller ctr1 = new Controller(31011,31001,31021);
/** Création de l'interface graphique **/ /** Création de l'interface graphique **/
ctr1.hisView=Interface.createAndShowGUI(ctr1); ctr1.hisView=Interface.createAndShowGUI(ctr1);

View file

@ -109,7 +109,7 @@ public class Historique {
this.bdd.close(); this.bdd.close();
} }
//MAIN //MAIN
public Historique() { public void Historique() {
this.bdd=new model.Database(); this.bdd=new model.Database();
System.out.println("coucoudb"); System.out.println("coucoudb");

View file

@ -22,7 +22,7 @@ public class Database {
} }
public Database() { public void Database() {
try { try {
Class.forName("java.sql.Driver"); Class.forName("java.sql.Driver");
System.out.println("coucou"); System.out.println("coucou");
@ -47,15 +47,15 @@ public class Database {
} }
int nb_changed_rows=0; int nb_changed_rows=0;
// try {
// nb_changed_rows = statement.executeUpdate("CREATE DATABASE base");
// System.out.println("coucou");
// } catch (SQLException e) {
// System.out.println("base de données pas établit");
// e.printStackTrace();
// }
try { try {
nb_changed_rows = statement.executeUpdate("USE tp_servlet_003"); nb_changed_rows = statement.executeUpdate("CREATE DATABASE base");
System.out.println("coucou");
} catch (SQLException e) {
System.out.println("base de données pas établit");
e.printStackTrace();
}
try {
nb_changed_rows = statement.executeUpdate("USE base");
System.out.println("coucou"); System.out.println("coucou");
} catch (SQLException e) { } catch (SQLException e) {
System.out.println("use base pas établit"); System.out.println("use base pas établit");