0

私は銀行システムを実装していましたが、クライアントに送信したいと考えてResultSetいます。しかし、Java はエラーを表示します。

    public interface SekelatonInterface extends Remote {

    public String test() throws RemoteException; // this is ok it works fine

    public ConnectionClass getConnection() throws RemoteException; //shows error on     client call

     public ResultSet getAllDeposits(Integer CustomerId) throws RemoteException;
  }

  public class SekelatonImpl extends UnicastRemoteObject implements SekelationInterface {



   SekelatonImpl() throws RemoteException{

   }

              //sekelaton implemeation
    public ConnectionClass getConnection() {

    try {
     dbobject = new ConnectionClass();
      dbobject.connectDb();
     dbObject.setQuery("select * from cutomer"); 
      return dbobject; //this method is on connection class ,dont be confuse

     }

     catch(Exception ex)

           {

        System.out.println("Error :"+ex.getMessage());
           }

    }

  }

   public class Server {


   public  void PackServerandRun(String SecurityFilePath,Integer port,String rmiUrl) {


   //do rmi registery stuff and run server
    SekelatonImpl  databaseObject = new SekelationImpl(); // rebind this object

    }

}
    cleintstub.test(); //this recive the server message or works fine
    cleintStub.getConnection(); //why couldn't i get a ConnectionClass Object ?

クライアントを実行すると、次のエラーが表示されます。

レジストリ ルックアップにエラーがあります。リターン ヘッダーのアンマーシャリング エラーです。ネストされた例外: java.io.EOFException

4

2 に答える 2

0

送りたいResultSet

残念ながら、できません。ResultSetありませんSerializable

またはクライアントへの接続オブジェクト、実際には後者は良い考えではありません。

それは「良いアイデア」ではないだけでなく、まったく無意味なアイデアです。電話線を介して電話を送ることはできません。同様に、別の接続を介して接続を送信することはできません。そうではないという事実は言うまでもConnectionありませんSerializable

しかし、Java はエラーを表示します。

次回問題レポートを投稿するときは、どこにでも、実際の問題を含めるようにしてください。これには、エラー メッセージ、逐語的、カット アンド ペースト、手動で転記されていないもの、ソース コードの関連セクション、必要に応じて行番号の表示が含まれます。 、および期待される出力と実際の出力。

catch(){
   }

例外を無視しないでください。そうしないと、デバッグが単なる推測ゲームになってしまいます。

于 2013-05-29T09:02:54.770 に答える
-1

問題を解決したいくつかの調査を行った後、私は自分の質問に答えようとします。

エラーはシリアル化されていないオブジェクトを送信していました。

ResultSet はシリアライゼーションをサポートしていないため、クライアントへのモデル クラス オブジェクトのモデル クラスとリターン リストも作成しました。パラメーターとして転送するすべてのクラスにシリアライゼーションを追加し、スケルトン実装のシリアライゼーションも含めることに注意してください。すべてのクラスをクライアント側で定義する必要があります。

 public class ConnectionClass implements java.io.Serializable {

 }

public interface SekelatonInterface extends Remote ,java.io.Serializable{

public Login getTestClass()throws RemoteException;

public String test() throws RemoteException;

public List<Login> getConnection() throws RemoteException;

public void sayHitoServer(String messages) throws RemoteException;

}
public class SkeletonInterfaceImpl extends UnicastRemoteObject implements      SekelatonInterface,Serializable {

  //implement all your skeleton methods
 }

 //this to change result set into model class to transefer it to client

public class Login {

private int Id;

private String Username;

private String Password;

public Login() {

}

public int getId() {
    return Id;
}

public void setId(int Id) {
    this.Id = Id;
}

public String getUsername() {
    return Username;
}

public void setUsername(String Username) {
    this.Username = Username;
}

public String getPassword() {
    return Password;
}

public void setPassword(String Password) {
    this.Password = Password;
}

public Login(ResultSet resultset){
    try{
    // resultset.next();
  Id = resultset.getInt("LoginId");
  Username =resultset.getString("Uname");
  Password = resultset.getString("Password");
          }
    catch(Exception ex){
    JOptionPane.showMessageDialog(null, "Error Setting Up Login"+ex.getMessage());

     }
   }
}

上記の方法はすべて問題なく機能しますが、ここでの問題は、モデルクラスのリストをjtableモデルにバインドしたいことです.TableModelに適した列を渡すにはどうすればよいですか?

于 2013-05-30T08:26:40.957 に答える