Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6069533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:49:57+00:00 2026-05-23T09:49:57+00:00

I have a JSF app with the DAO layer implemented for Hibernate (also using

  • 0

I have a JSF app with the DAO layer implemented for Hibernate (also using Spring for transaction management).

The problem I’m having is occasionally the database goes down and when this happens I want the JSF app to redirect to a “Lost connection to the database” page.

There’s two approaches I can think of to handle this:

(1) a phase listener that tests the database connection on every request and redirects if the database is not there; (except that means an extra database query on every web app request)

(2) have every method in every DAO throw some kind of “NoDBConnectionExcepiton” and catch that exception in the backing beans and redirect there (except that means writing a lot of exception handling code)

Does anyone have any ideas? Suggestion and advice are appreciated!

Rob

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:49:58+00:00Added an answer on May 23, 2026 at 9:49 am

    have every method in every DAO throw some kind of “NoDBConnectionExcepiton”

    I’d go for this. You can let it be a subclass of some exception which it is already throwing, so that you don’t need to change the throws or catch clauses. For example, a subclass of SQLException maybe?

    and catch that exception in the backing beans and redirect there (except that means writing a lot of exception handling code)

    Not necessarily. You can define a custom error page for a specific exception in web.xml so that the container will handle it by itself.

    <error-page>
        <exception-type>com.example.NoDBConnectionException</exception-type>
        <location>/errors/dbconnection.html</location>
    </error-page>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a simple JSF image browsing app, and I'm having a problem
Here is my scenario: I have my-jsf-app.war (JSF 1.2 application) and daos-and-entities.har (Hibernate 3.3.1)
I have JSF + Hibernate app. During runtime, i need to change database, to
I have a JSF 2.1 (MyFaces) app running using several Session Beans (All the
I have web application wich uses jsf 2.0 and spring 3.0 The problem is
I have JSF web app on glassfish using j_security_check validation with jdbcRealm on glassfish
I have a problem with duplicated ids in my JSF app. I've read in
i have a simple problem here i am making a simple jsf web app
I have a small JSF app and would like to keep some state on
i have a JSF web application. I use Beans as Spring Beans (not JSF

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.