I am working on the web services to get some user details from Database. I am unaware of throwing and handling the exceptions.
@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;
}
I want to catch the exception at client side and I want to modify the error message like "Unable to connect to Database"
.
Can any one tell how to do that and send custom exceptions too.
Thanks in Advance.
Take a look of following tutorial:
For your function you can write it like that
public UserDetails getUserInfo(@WebParam(name="mailID")int mailID) throws SQLException{
// if your connection not established then
throw new SQLException("Unable to connect to Database");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.