Programmation RMI
Résolu
aymenboss
-
aymenboss -
aymenboss -
Bonjour,
slt je besoin de m'aider à mon projet je veut que tu me corrige mes faute s'il te plait bon le projet est :
voila exercice:
une compagnie aérienne offre un service de reservavtion accessible à distance chaque vol est défini par son numero (identifiant unique ),pays de départ ,pays destination ,heure , nombre de place non encore réservéés et prix du tiket
le service offre trois opérations
1_reserver : à paritr d'un nom de client , un numero de vol et d'une date . cette opération renvois un entier qui correspond au numero du ticket si réservation réussie ou -1 sinon
2_annuler à partir d'un numero de vol et un tiket cette opération annule la réseravation corespondante .elle retourne 1 si annulation réussie ,0 si paramétre d'entréé non valides
3_ lister à partir d'une date , de pays départ et destination ,cette opération rend les numéros et les horaires ainsi que le prix de ticket des vols corresondant à ces paramétres de recherche
question :
réaliset en java RMI une implémentation du systéme décrit ci-dessus
et voila le code que je l'écris pour le client dabor :
public interface AgenceInterface extends java.rmi.Remote {
public int[] reserver(String nomClient,int numVol,String dateV,String NomHotel,String dateH,int nbChambre) throws java.rmi.RemoteException;
public int annuler(int numVol,int numTicket,int numReservation) throws java.rmi.RemoteException;
public String[] listerV(String date ,String paysDepart,String paysDestination) throws java.rmi.RemoteException;
public String[] listerH(int numReservation) throws java.rmi.RemoteException;
}
pour le serveur :
public class AgenceServeur extends UnicastRemoteObject implements AgenceInterface {
Connection cn;
Statement st;
public AgenceServeur() throws java.rmi.RemoteException { }
public int[] reserver(String nomClient,int numVol,String dateV,String nomHotel,String dateH,int nbChambre) throws java.rmi.RemoteException {
int numTicket=-1;
int numReservation=-1;
int reservation[]={numTicket,numReservation};
try{
InterfaceVol obj = (InterfaceVol) Naming.lookup ("rmi://localhost:1099/volServeur");
numTicket = obj.reserverV(nomClient,numVol,dateV);
InterfaceHotel obj1 = (InterfaceHotel) Naming.lookup ("rmi://localhost:1099/hotelServeur");
numReservation = obj1.reserverH(nomClient,nomHotel,dateH,nbChambre);
reservation[0]=numTicket;
reservation[1]=numReservation;
}
catch (SQLException ex) {
System.out.println(ex.getMessage());
return reservation;
}
catch (ClassNotFoundException ex) {
return reservation;
}
catch (NotBoundException ex) {
System.out.println("Erreur NotBoundException");
return reservation;
}
catch (MalformedURLException ex) {
System.out.println("Erreur MalformedURLException");
return reservation;
}
catch (RemoteException ex) {
System.out.println("Erreur RemoteException");
return reservation;
}
}
public int annuler(int numVol,int numTicket,int numReservation) throws java.rmi.RemoteException {
int testVol;
int testHotel;
try{
InterfaceVol obj = (InterfaceVol) Naming.lookup ("rmi://localhost:1099/volServeur");
testVol = obj.annulerV(numVol,numTicket);
InterfaceHotel obj1 = (InterfaceHotel) Naming.lookup ("rmi://localhost:1099/hotelServeur");
testHotel = obj1.annulerH(numReservation);
return(1);
}
else
return(0);
}
catch (SQLException ex) {
return(0);
}
catch (ClassNotFoundException ex) {
return(0);
}
catch (NotBoundException ex) {
return(0);
}
catch (MalformedURLException ex) {
return(0);
}
catch (RemoteException ex) {
return(0);
}
}
public String[] listerV(String date ,String paysDepart,String paysDestination) throws java.rmi.RemoteException {
String[] rs={" "," "," "} ;
try{
InterfaceVol obj = (InterfaceVol) Naming.lookup ("rmi://localhost:1099/volServeur");
rs = obj.listerV(date,paysDepart,paysDestination);
}
/*
catch (SQLException ex) {
System.out.println("Erreur Sql");
rs = null;
}
*/
catch (NotBoundException ex) {
System.out.println("Erreur NotBoundException");
rs=null;
}
catch (RemoteException ex) {
System.out.println("Erreur RemoteException");
rs=null;
}
catch (MalformedURLException ex) {
System.out.println("Erreur MalformedURLException");
rs=null;;
}
return(rs);
}//fin listerV()
public String[] listerH(int numReservation) throws java.rmi.RemoteException {
String info="Reservation introuvable";
String s[];
try{
InterfaceHotel obj = (InterfaceHotel) Naming.lookup ("rmi://localhost:1099/hotelServeur");
s = obj.listerH(numReservation);
}
catch (NotBoundException ex) {
s=null;
}
catch (RemoteException ex) {
s= null ;
}
catch (MalformedURLException ex) {
s=null;
}
return(s) ;
}
public static void main(String args[]) throws IOException {
try{
AgenceServeur monServeur = new AgenceServeur();
Naming.rebind("rmi://localhost:1099/AgenceServeur", monServeur);
}
catch (RemoteException e) {
System.out.println("AgenceServeur err: " + e.getMessage());
}
}
}
stp m'aider je veut que sera éxécutable merci
slt je besoin de m'aider à mon projet je veut que tu me corrige mes faute s'il te plait bon le projet est :
voila exercice:
une compagnie aérienne offre un service de reservavtion accessible à distance chaque vol est défini par son numero (identifiant unique ),pays de départ ,pays destination ,heure , nombre de place non encore réservéés et prix du tiket
le service offre trois opérations
1_reserver : à paritr d'un nom de client , un numero de vol et d'une date . cette opération renvois un entier qui correspond au numero du ticket si réservation réussie ou -1 sinon
2_annuler à partir d'un numero de vol et un tiket cette opération annule la réseravation corespondante .elle retourne 1 si annulation réussie ,0 si paramétre d'entréé non valides
3_ lister à partir d'une date , de pays départ et destination ,cette opération rend les numéros et les horaires ainsi que le prix de ticket des vols corresondant à ces paramétres de recherche
question :
réaliset en java RMI une implémentation du systéme décrit ci-dessus
et voila le code que je l'écris pour le client dabor :
public interface AgenceInterface extends java.rmi.Remote {
public int[] reserver(String nomClient,int numVol,String dateV,String NomHotel,String dateH,int nbChambre) throws java.rmi.RemoteException;
public int annuler(int numVol,int numTicket,int numReservation) throws java.rmi.RemoteException;
public String[] listerV(String date ,String paysDepart,String paysDestination) throws java.rmi.RemoteException;
public String[] listerH(int numReservation) throws java.rmi.RemoteException;
}
pour le serveur :
public class AgenceServeur extends UnicastRemoteObject implements AgenceInterface {
Connection cn;
Statement st;
public AgenceServeur() throws java.rmi.RemoteException { }
public int[] reserver(String nomClient,int numVol,String dateV,String nomHotel,String dateH,int nbChambre) throws java.rmi.RemoteException {
int numTicket=-1;
int numReservation=-1;
int reservation[]={numTicket,numReservation};
try{
InterfaceVol obj = (InterfaceVol) Naming.lookup ("rmi://localhost:1099/volServeur");
numTicket = obj.reserverV(nomClient,numVol,dateV);
InterfaceHotel obj1 = (InterfaceHotel) Naming.lookup ("rmi://localhost:1099/hotelServeur");
numReservation = obj1.reserverH(nomClient,nomHotel,dateH,nbChambre);
reservation[0]=numTicket;
reservation[1]=numReservation;
}
catch (SQLException ex) {
System.out.println(ex.getMessage());
return reservation;
}
catch (ClassNotFoundException ex) {
return reservation;
}
catch (NotBoundException ex) {
System.out.println("Erreur NotBoundException");
return reservation;
}
catch (MalformedURLException ex) {
System.out.println("Erreur MalformedURLException");
return reservation;
}
catch (RemoteException ex) {
System.out.println("Erreur RemoteException");
return reservation;
}
}
public int annuler(int numVol,int numTicket,int numReservation) throws java.rmi.RemoteException {
int testVol;
int testHotel;
try{
InterfaceVol obj = (InterfaceVol) Naming.lookup ("rmi://localhost:1099/volServeur");
testVol = obj.annulerV(numVol,numTicket);
InterfaceHotel obj1 = (InterfaceHotel) Naming.lookup ("rmi://localhost:1099/hotelServeur");
testHotel = obj1.annulerH(numReservation);
return(1);
}
else
return(0);
}
catch (SQLException ex) {
return(0);
}
catch (ClassNotFoundException ex) {
return(0);
}
catch (NotBoundException ex) {
return(0);
}
catch (MalformedURLException ex) {
return(0);
}
catch (RemoteException ex) {
return(0);
}
}
public String[] listerV(String date ,String paysDepart,String paysDestination) throws java.rmi.RemoteException {
String[] rs={" "," "," "} ;
try{
InterfaceVol obj = (InterfaceVol) Naming.lookup ("rmi://localhost:1099/volServeur");
rs = obj.listerV(date,paysDepart,paysDestination);
}
/*
catch (SQLException ex) {
System.out.println("Erreur Sql");
rs = null;
}
*/
catch (NotBoundException ex) {
System.out.println("Erreur NotBoundException");
rs=null;
}
catch (RemoteException ex) {
System.out.println("Erreur RemoteException");
rs=null;
}
catch (MalformedURLException ex) {
System.out.println("Erreur MalformedURLException");
rs=null;;
}
return(rs);
}//fin listerV()
public String[] listerH(int numReservation) throws java.rmi.RemoteException {
String info="Reservation introuvable";
String s[];
try{
InterfaceHotel obj = (InterfaceHotel) Naming.lookup ("rmi://localhost:1099/hotelServeur");
s = obj.listerH(numReservation);
}
catch (NotBoundException ex) {
s=null;
}
catch (RemoteException ex) {
s= null ;
}
catch (MalformedURLException ex) {
s=null;
}
return(s) ;
}
public static void main(String args[]) throws IOException {
try{
AgenceServeur monServeur = new AgenceServeur();
Naming.rebind("rmi://localhost:1099/AgenceServeur", monServeur);
}
catch (RemoteException e) {
System.out.println("AgenceServeur err: " + e.getMessage());
}
}
}
stp m'aider je veut que sera éxécutable merci
A voir également:
- Programmation RMI
- Application de programmation - Guide
- Programmation envoi sms - Guide
- Programmation binaire - Guide
- Programmation vb - Télécharger - Langages
- Programmation télécommande porte de garage brico depot - Forum Matériel & Système
5 réponses
bonjour!!
NON!!! CCM n'est pas là pour faire tes devoirs ou tes exercices à ta place...
et un petit cours de français ne te ferait pas de mal...
NON!!! CCM n'est pas là pour faire tes devoirs ou tes exercices à ta place...
et un petit cours de français ne te ferait pas de mal...
mais je veu pa que travaillle je veu que tu corrige le code car je sai pa commment le faire car je veu que mon projet sera écutable sitou
et vous comment tu m'aide je comprond pas que vous fassse koi pour nous aides mai je sache que vous develloper alors c'est facile de m'aider
CCM n'est pas là pour faire tes devoirs ou tes exercices à ta place...
et un petit cours de français ne te ferait pas de mal...
et un petit cours de français ne te ferait pas de mal...
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question