bdd
This commit is contained in:
parent
233fcfd78c
commit
877736d080
3 changed files with 22 additions and 19 deletions
|
@ -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) {
|
private Controller(int portUDPsend,int portUDPlistening,int portTCP,Historique histoire) {
|
||||||
this.histoire= new Historique();
|
this.histoire= histoire;
|
||||||
|
|
||||||
InetAddress addIP = null;
|
InetAddress addIP = null;
|
||||||
try
|
try
|
||||||
|
@ -97,7 +97,8 @@ 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) {
|
private Controller(int portUDPsend,int portUDPlistening,int portTCP,String pseudo,Historique histoire) {
|
||||||
|
this.histoire=histoire;
|
||||||
InetAddress addIP = null;
|
InetAddress addIP = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -362,6 +363,7 @@ public class Controller {
|
||||||
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());
|
||||||
|
@ -376,8 +378,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(dateFormat.format(date));
|
out.println(dateString);
|
||||||
out.println(message);
|
out.println(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,13 +493,14 @@ public class Controller {
|
||||||
|
|
||||||
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");
|
Controller ctr2 = new Controller(31012,portUDPlistening_remoteUsr2,31022,"Mike",histoire);
|
||||||
// REMOTEUSER_2 - ALICE
|
// REMOTEUSER_2 - ALICE
|
||||||
Controller ctr3 = new Controller(31013,portUDPlistening_remoteUsr3,31023,"Alice");
|
Controller ctr3 = new Controller(31013,portUDPlistening_remoteUsr3,31023,"Alice",histoire);
|
||||||
// LOCAL USER
|
// LOCAL USER
|
||||||
Controller ctr1 = new Controller(31011,31001,31021);
|
Controller ctr1 = new Controller(31011,31001,31021,histoire);
|
||||||
|
|
||||||
/** Création de l'interface graphique **/
|
/** Création de l'interface graphique **/
|
||||||
ctr1.hisView=Interface.createAndShowGUI(ctr1);
|
ctr1.hisView=Interface.createAndShowGUI(ctr1);
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class Historique {
|
||||||
this.bdd.close();
|
this.bdd.close();
|
||||||
}
|
}
|
||||||
//MAIN
|
//MAIN
|
||||||
public void Historique() {
|
public Historique() {
|
||||||
|
|
||||||
this.bdd=new model.Database();
|
this.bdd=new model.Database();
|
||||||
System.out.println("coucoudb");
|
System.out.println("coucoudb");
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class Database {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Database() {
|
public 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("CREATE DATABASE base");
|
nb_changed_rows = statement.executeUpdate("USE tp_servlet_003");
|
||||||
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");
|
||||||
|
|
Loading…
Reference in a new issue