开发者

How to handle database connection down in GWT application

开发者 https://www.devze.com 2023-02-17 15:33 出处:网络
I handle a website which is designed in GWT and I want to check if database connection goes down in between accessing the website. If database connection is down I want to give message as cannot conne

I handle a website which is designed in GWT and I want to check if database connection goes down in between accessing the website. If database connection is down I want to give message as cannot connect to server.

Can anybody suggest what will be the best way to handle this?

I know the onFailure(Throwable t) method on AsyncCallback is there. This method is called when the RPC fails for any reason, including (but not limited 开发者_开发技巧to) loss of connection.


Why not throw a meaningful exception from the RPC service on DB failure and handle the scenario inside onFailure of GWT RPC? You should extend AsyncCallback and handle all such general failure conditions (DB/NW failure etc...) at a single place and subclass this callback everywhere instead of defining new AsyncCallback instances each time.

0

精彩评论

暂无评论...
验证码 换一张
取 消