This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Comment

In my application i am rendering homepage by reading entries from a databse.
If that database is down or couldnt retrive a connection to query. Then i wanted to disply an error message saying that "connection failed!".
Not only for this home page but through out the application if connection lost or DB goes down proper error message should be displayed.

Currently i am catching a SQLException in Controller and in that cath block i am rejecting a value using errors.rejectValue(....). With this approach each time if i dip into DB I must catch an SQLException? Or any better approach.

Comment

hi,
IMHO, catching SQLException and populating various error messages shoudl be fine..
you are already doing what you would like to do.. you can't connect to DB, code raises a SQLException and you act accordingly..

unless you want some other fancy features.. in that case could you elaborate better what you would like to achieve?