Announcement Announcement Module
No announcement yet.
Spring MVC and hibernate connected to two database Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring MVC and hibernate connected to two database

    Hi All,

    I am using the spring MVC and hibernate to connect to two database, out of which is one is for the only read, so not using transaction manager for that..
    in hibernate DAO I am binding the session factory for another database...
    if read only database is down , I want to give message to the user that this database is down and if you want to continue with the application in read only mode.
    How to do this , need your assistance?

    Thnx in advance.....

  • #2
    I assume, that you intended to write "if read-write database is down".
    One way would be to use an interceptor, as checking the database is a cross-cutting concern. The state of the database (up/down) could be stored in a session variable.
    So every time the user invokes a controller, the interceptor checks the database and if it has changed its state, displays the view, that asks about continuing or not.
    To make it more robust, you could throw a special exception in case of database failure and add an exception handler that also forwards to that view and sets the state variable.