The JDBC URL for Oracle’s Data Guard Fast-Start Failover

jdbcoracle

Currently I have…

url=
"
  jdbc:oracle:thin:@
    (
    DESCRIPTION=
      (
      ADDRESS_LIST=
        (LOAD_BALANCE=OFF)
        (FAILOVER=ON)
        (
        ADDRESS=
          (PROTOCOL=TCP)
          (HOST=10.0.0.6)
          (PORT=1521)
        )
        (
        ADDRESS=
          (PROTOCOL=TCP)
          (HOST=10.0.0.7)
          (PORT=1521)
        )
      )
      (
      CONNECT_DATA=
        (SERVICE_NAME=mySID.nowhere.org)
        (SERVER=DEDICATED)
      )
     )
"

Best Answer

You don't setup Fast-Start Failover in the URL. It's something that you setup on the data source using the setFastConnectionFailoverEnabled(true) function call.

Per here

An application enables Fast Connection Failover by calling setFastConnectionFailoverEnabled(true) on a DataSource instance, before retrieving any connections from that instance.

You cannot enable Fast Connection Failover when reinitializing a connection cache. You must enable it before using the OracleDataSource instance.

For example

    ods = new OracleDataSource();
    ...
    ods.setFastConnectionFailoverEnabled(true);

Also, it mentions:

FAST CONNECTION FAILOVER PREREQUISITES

1.) The implicit connection cache is enabled. Fast Connection Failover works in conjunction with the JDBC connection caching mechanism. This helps applications manage connections to ensure high availability.

2.) The application uses service names to connect to the database; the application cannot use service IDs (ORACLE_SID). Use a service name rather than an SID when setting the OracleDataSource url property.

3.) The underlying database has Release 10 (10.1) or Release 10 (10.2) Real Application Clusters (RAC) capability. If failover events are not propagated, connection failover cannot occur.

4.) Oracle Notification Service (ONS) is configured and available on the node where JDBC is running and on the Oracle RAC. JDBC depends on ONS to propagate database events from RAC and notify JDBC of them. If ONS is not correctly set up, then implicit connection cache creation fails and an ONSException is thrown at the first getConnection request.

5.) The JVM in which your JDBC instance is running must have oracle.ons.oraclehome set to point to your ORACLE_HOME. For example:

-Doracle.ons.oraclehome=C:\oracle\product\10.2.0\db_1

6.) Set the FastConnectionFailoverEnabled property before making the first getConnection request to an OracleDataSource. When Fast Connection Failover is enabled, the failover applies to all connections in the connection cache. If your application explicitly creates a connection cache using the Connection Cache Manager, then you must first set FastConnectionFailoverEnabled before retrieving any connections.

7.) The ons.jar must be part of the CLASSPATH for the application. The ons.jar can be found in the Oracle Client installation.


Edit: One last thought, if there ever is a failover, you will need to handle the SQLException:

ORA-17008: Closed Connection