• 1 reply
  • Latest Post - ‏2010-12-29T09:27:46Z by SystemAdmin
1 Post

Pinned topic Database Failover Question

‏2010-12-21T02:59:28Z |
We are using a SQL Server database and using MS driver for SQL Server.

The database connection is done by the following code

In the EJB Deployment Descriptor, we have the following code for database connectivity

<resource-ref id="ResourceRef_1218093177156">
<description>JDBC DataSource</description>
public final static String jndiDSName="java:comp/env/jdbc/dsDBRef";

dataSource = (DataSource)ServiceLocator.getDataSource(jndiDSName);
connection = dataSource.getConnection();

The connection is working perfectly fine.
We want to do a database failover for the application.
If the primary database fails, we would need to connect to a different machine and use that database.

Can anyone give some specific information on to how to acheive this.
Updated on 2010-12-29T09:27:46Z at 2010-12-29T09:27:46Z by SystemAdmin
  • SystemAdmin
    4447 Posts

    Re: Database Failover Question

    just a thought :

    create a second datasource.

    then :
    try {
    dataSource = (DataSource)ServiceLocator.getDataSource(jndiDSName);
    connection = dataSource.getConnection();
    }catch (XYZException e) { // naming, sql, etc.
    dataSource2 = (DataSource) ServiceLocator.getDataSource(jndiDSName2);
    connection = dataSource2.getConnection();