0

私はデータベースからユーザーの詳細を取得するためにWebサービスに取り組んでいます。私は例外をスローして処理することに気づいていません。

@WebMethod(operationName ="My operataion")
    @WebResult(name="Some Type")
    public UserDetails getUserInfo(@WebParam(name="mailID")int mailID) throws SQLException{
        UserDetails user= new UserDetails();
        User umanager= new User();
        user= umanager.getUserInfo(custID);
        return user;


    }

クライアント側で例外をキャッチしたいのですが、のようなエラーメッセージを変更したいと思います"Unable to connect to Database"

誰かがそれを行う方法を教えて、カスタム例外も送信できますか?

前もって感謝します。

4

1 に答える 1

1

次のチュートリアルをご覧ください。

  1. 例外をスローする

あなたの関数のためにあなたはそれをそのように書くことができます

public UserDetails getUserInfo(@WebParam(name="mailID")int mailID) throws SQLException{
    // if your connection not established then   
    throw new SQLException("Unable to connect to Database");
}
于 2013-01-08T06:48:47.610 に答える