How can I handle DB connection errors in Play 1.X?

I am writing a status page that checks various system services and displays their status.

As part of my testing, I close my database and want to check if it is working or not and make that fact on the page.

However, when the database is closed, I cannot show any page - instead, I get this error before running my code:

org.hibernate.exception.GenericJDBCException: Cannot open connection

      

Play tries to open a transaction, fails and kills my entire page.

How can I get around this for this particular page , manually check the DB connection and act accordingly instead of failing the entire page?

+3


source to share


1 answer


Use @NoTransaction annotation on your controller method to avoid opening a transaction



+1


source







All Articles