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
|
||||
* </p>
|
||||
*/
|
||||
private Controller(int portUDPsend,int portUDPlistening,int portTCP) {
|
||||
this.histoire= new Historique();
|
||||
private Controller(int portUDPsend,int portUDPlistening,int portTCP,Historique histoire) {
|
||||
this.histoire= histoire;
|
||||
|
||||
InetAddress addIP = null;
|
||||
try
|
||||
|
@ -97,7 +97,8 @@ public class Controller {
|
|||
* - notification aux autres utilisateurs actifs
|
||||
* </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;
|
||||
try
|
||||
{
|
||||
|
@ -362,6 +363,7 @@ public class Controller {
|
|||
date = new Date();
|
||||
date1.setTime(date);
|
||||
dateString=date1.toString();
|
||||
this.getHistory().saveMessage(getMyUser(), c.getRemoteUser(),message ,dateString );
|
||||
|
||||
/*
|
||||
System.out.println(this.getHistory());
|
||||
|
@ -376,8 +378,8 @@ public class Controller {
|
|||
//this.getHistory().saveMessage(this.myUser, c.getRemoteUser(),message ,dateString);
|
||||
|
||||
// Envoie du message (avec la date)
|
||||
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||||
out.println(dateFormat.format(date));
|
||||
//DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||||
out.println(dateString);
|
||||
out.println(message);
|
||||
}
|
||||
|
||||
|
@ -491,13 +493,14 @@ public class Controller {
|
|||
|
||||
Historique histoire=new Historique();
|
||||
|
||||
|
||||
/** Création des utilisateurs **/
|
||||
// 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
|
||||
Controller ctr3 = new Controller(31013,portUDPlistening_remoteUsr3,31023,"Alice");
|
||||
Controller ctr3 = new Controller(31013,portUDPlistening_remoteUsr3,31023,"Alice",histoire);
|
||||
// LOCAL USER
|
||||
Controller ctr1 = new Controller(31011,31001,31021);
|
||||
Controller ctr1 = new Controller(31011,31001,31021,histoire);
|
||||
|
||||
/** Création de l'interface graphique **/
|
||||
ctr1.hisView=Interface.createAndShowGUI(ctr1);
|
||||
|
|
|
@ -109,7 +109,7 @@ public class Historique {
|
|||
this.bdd.close();
|
||||
}
|
||||
//MAIN
|
||||
public void Historique() {
|
||||
public Historique() {
|
||||
|
||||
this.bdd=new model.Database();
|
||||
System.out.println("coucoudb");
|
||||
|
|
|
@ -22,7 +22,7 @@ public class Database {
|
|||
}
|
||||
|
||||
|
||||
public void Database() {
|
||||
public Database() {
|
||||
try {
|
||||
Class.forName("java.sql.Driver");
|
||||
System.out.println("coucou");
|
||||
|
@ -47,15 +47,15 @@ public class Database {
|
|||
}
|
||||
|
||||
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 {
|
||||
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");
|
||||
nb_changed_rows = statement.executeUpdate("USE tp_servlet_003");
|
||||
System.out.println("coucou");
|
||||
} catch (SQLException e) {
|
||||
System.out.println("use base pas établit");
|
||||
|
|
Loading…
Reference in a new issue