dbb
This commit is contained in:
parent
fc16e1a74e
commit
c0731ba406
4 changed files with 17 additions and 6 deletions
|
@ -1,4 +1,7 @@
|
|||
package controller;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
|
@ -8,7 +11,7 @@ import java.sql.Statement;
|
|||
import java.util.Calendar;
|
||||
|
||||
public class Historique {
|
||||
private Database bdd;
|
||||
private model.Database bdd;
|
||||
private ResultSet rs_received;
|
||||
private ResultSet rs_sent;
|
||||
private ResultSetMetaData rsmd_received;
|
||||
|
@ -43,12 +46,12 @@ public class Historique {
|
|||
return this.rsmd_sent;
|
||||
}
|
||||
|
||||
public void saveMessage(User user1, RemoteUser user2, String input, String date) {
|
||||
public void saveMessage(model.User ctr1, model.RemoteUser ctr2, String input, String date) {
|
||||
System.out.println("coucou");
|
||||
|
||||
int nb_changed_rows=0;
|
||||
try {
|
||||
nb_changed_rows = this.bdd.getStatement().executeUpdate("INSERT INTO chat values ("+user1.getIPcode()+","+user2.addIP+","+input+","+date+")");
|
||||
nb_changed_rows = this.bdd.getStatement().executeUpdate("INSERT INTO chat values ("+ctr1.getIPcode()+","+ctr2.getIPcode()+","+input+","+date+")");
|
||||
} catch (SQLException e) {
|
||||
System.out.println("insertion pas établit");
|
||||
e.printStackTrace();
|
||||
|
@ -59,7 +62,7 @@ public class Historique {
|
|||
}
|
||||
}
|
||||
|
||||
public String retrieveMessage(User user1, RemoteUser user2) throws SQLException {
|
||||
public String retrieveMessage(model.User user1, model.RemoteUser user2) throws SQLException {
|
||||
this.setRSSent(this.bdd.getStatement().executeQuery("SELECT"+user1.getIPcode()+","+user2.getIPcode()+",? ,? FROM table"));
|
||||
this.setRSReceived(this.bdd.getStatement().executeQuery("SELECT"+user2.getIPcode()+","+user1.getIPcode()+",?, ? FROM table"));
|
||||
//this.setRSMDSent(this.getRSSent().getMetaData());
|
||||
|
@ -108,7 +111,7 @@ public class Historique {
|
|||
//MAIN
|
||||
public void Historique() {
|
||||
|
||||
this.bdd=new Database();
|
||||
this.bdd=new model.Database();
|
||||
System.out.println("coucoudb");
|
||||
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ public class ListeningThreadTCPConnection extends ListeningThread{
|
|||
threadtcpchat.start();
|
||||
threadtcpchat.interrupt();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* run
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
package model;
|
||||
|
||||
import java.sql.Connection;
|
||||
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
|
|
@ -26,6 +26,7 @@ public abstract class User {
|
|||
protected String pseudo;
|
||||
protected InetAddress addIP;
|
||||
protected int portTCP;
|
||||
protected int IPcode;
|
||||
|
||||
/**
|
||||
* Constructor of User (local)
|
||||
|
@ -42,10 +43,14 @@ public abstract class User {
|
|||
this.pseudo = pseudo;
|
||||
this.addIP=addIP;
|
||||
this.portTCP=portTCP;
|
||||
this.IPcode=addIP.hashCode();
|
||||
}
|
||||
|
||||
|
||||
/*** GETTERS ***/
|
||||
public int getIPcode() {
|
||||
return IPcode;
|
||||
}
|
||||
public String getPseudo() {
|
||||
return pseudo;
|
||||
}
|
||||
|
@ -56,6 +61,7 @@ public abstract class User {
|
|||
return portTCP;
|
||||
}
|
||||
|
||||
|
||||
/*** SETTERS ***/
|
||||
public void setPseudo(String pseudo) {
|
||||
this.pseudo = pseudo;
|
||||
|
|
Loading…
Reference in a new issue