hajhag
Messages postés7Date d'inscriptionvendredi 22 février 2008StatutMembreDernière intervention16 août 2012
-
13 août 2012 à 19:58
hajhag
Messages postés7Date d'inscriptionvendredi 22 février 2008StatutMembreDernière intervention16 août 2012
-
16 août 2012 à 15:45
HAGOUGUI
Bonjour
Merci de prêter votre attention à ma question,je viens de réaliser un petit
exemple RMI avec Une Base de Données MYSQL sous netbeans dans la même machine JVM.
ceci dans le but de se familiariser avec ce type d'application distribuée
j'ai créer toutes les classes nécessaires pour faire le tourner ,mais le problème quand j'exécute le client rien n'est affiché,j'ai beaucoup cherché ça fait déjà un bon nombre d'heures si non de jours .
Ma question est ce que j'ai omis une étape qui empêche l'affichage dans le fram Client
Mecri d'avoir donner une idée
Les classes Sont :
InterfaceBdRmi,ImplementBdRmi,ClientBdRmi Et ServerBdRmi
Bien sûr avant d’exécuter la Classe ClientBdRmi je passe par les étapes
suivantes:
dans le chemin class
rmic agenda.ImplementBdRmi
rmiregitry
Run via Netbeans ServeurBdRmi
Ma base Agendarmi contient une seule table TESTRMI
avec user Client password 123456
ID int 10
Nom Varchar 30
Email varchar 30
..................................................
Classe InterfaceBdRMI
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package agenda;
public interface InterfaceBdRmi extends Remote {
public String consultation(int sid) throws RemoteException;
public String consultationemail(int sid) throws RemoteException;
}
.........................
Classe ImplementBdrmi
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package agenda;
public String consultation(int sid) throws RemoteException {
String s = null;
try{
System.out.println("HAGGAGAGAG ImplementBdRmi");
Connection minconnect = connect();
Statement st = minconnect.createStatement();
ResultSet rs st.executeQuery("select * from testrmi where id "+sid);
while (rs.next()){
s=(rs.getString(2)) ;
}
minconnect.close();
st.close();
rs.close();
return s;
}
catch(SQLException ex){
System.out.println(ex.getMessage());
return null;
}
catch(Exception e){
System.out.println(e.getMessage());
return null;
}
}
public String consultationemail(int sid) throws RemoteException {
String s = null;
try{
Connection minconnect = connect();
Statement st = minconnect.createStatement();
ResultSet rs st.executeQuery("select * from testrmi where id "+sid);
while (rs.next()){
s=(rs.getString(3)) ;
}
minconnect.close();
st.close();
rs.close();
return s;
}
catch(SQLException ex){
System.out.println(ex.getMessage());
return null;
}
catch(Exception e){
System.out.println(e.getMessage());
return null;
}
}
public String consultation() throws RemoteException {
throw new UnsupportedOperationException("Not supported yet.");
}
public String consultationemail() throws RemoteException {
throw new UnsupportedOperationException("Not supported yet.");
}
}
// End OF FILE
......................
Classe ServerBdRMI
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package agenda;
import agenda.ImplementBdRmi;
import java.rmi.Naming;
public class ServerBdRmi {
public ServerBdRmi(){
try{
}
}
public static void main(String[] args) {
new ServerBdRmi();
}
}
// END OF FILE
.......................
Classes ClientBdRmi
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* ClientBdRmi.java
*
* Created on 10 août 2012, 18:46:41
*/
package agenda;
import java.rmi.Naming;
public class ClientBdRmi extends javax.swing.JFrame {
/** Creates new form ClientBdRmi */
public ClientBdRmi() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
panel1 = new java.awt.Panel();
txt_id = new java.awt.TextField();
b_consultation = new java.awt.Button();
txt_nom = new javax.swing.JTextField();
txt_email = new javax.swing.JTextField();