1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
| public class Client {
public String nom;
public String pass;
public fctInterface stub;
public File file = new File("BDDServeur1.ser");
public Client (String nom, String pass) {
this.nom = nom;
this.pass = pass;
}
public Client() {
this.nom = "";
this.pass = "";
}
//avec un numPort
public void connexionServ() throws RemoteException {
Registry registry = LocateRegistry.getRegistry(10000);
try {
this.stub = (fctInterface) registry.lookup("fct");
} catch (Exception e) {
e.printStackTrace();
}
}
public void ClientLireDonnee (File file) {
try {
this.stub.lireTout(file);
} catch (Exception e) {
e.printStackTrace();
}
}
public void ClientAjouterDonnee (ArrayList<table> table) {
try {
this.stub.AjouterDonnee(file, table);
} catch (Exception e) {
e.printStackTrace();
}
}
public void supprimerDonnee () {
try {
this.stub.supprimerDonnee();
} catch (Exception e) {
e.printStackTrace();
}
}
public void modifierDonnee () {
try {
this.stub.modifierDonnee();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main (String[] args){
try {
table t1 = new table(1,"sara","sasa");
table t2 = new table(2,"lana", "justin");
ArrayList<table> list = new ArrayList<table>();
File file = new File("BDDServeur1");
Client cl = new Client();
cl.file = file;
Registry registry = LocateRegistry.getRegistry(10000);
cl.stub = (fctInterface) registry.lookup("fct");
cl.ClientAjouterDonnee( list);
cl.ClientLireDonnee(file);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NotBoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} |
Partager