Announcement Announcement Module
Collapse
No announcement yet.
How to "reload" datasource Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to "reload" datasource

    Hi,

    Not sure if this is a bean factory question or data access question, but anyway ...

    I am just wondering how to deal with DBMS crash or periodic shutdown. The datasource is instantiated at application startup and injected into transaction manager and DAO beans.

    Now, if the DBMS goes down for a brief period and the connection is lost, how do we re-instantiate the datasource, and fix up all references to it from other beans?

  • #2
    A datasource doesn't have a connection to the database. It is a means to a Connection to a database via getConnection() using the connection parameters specified when it was created.

    So regardless of your database running or not, the same DataSource will function as intended.... it'll throw exceptions when getConnection is called, until the database comes back up.

    Comment


    • #3
      DataSource providers generally manage internal pool of connections, this means if your database shuts down for a short period, the connections in the pool may not be reusable.
      Jakarta cmmons DBCP provides configuration parameters to turn on detection and eviction of invalid connections (testOnBorrow, testOnReturn, testWhileIdle...).
      Please review the documentation of the datasource you use for more informations.
      Hope this helps.

      Comment

      Working...
      X