NCSU44
NCSU44

Reputation: 21

Can I use a JDBC driver for Application failover to the correct Oracle DB instance (Data Guard, not RAC cluster)

Can I use a driver for Application failover to the correct Oracle DB instance (Data Guard, not RAC cluster)

The documentation seems to suggest I can with a RAC cluster, I am not sure if I can with Data Guard Primary and Standby instance. I want to do this to avoid sing a GSLB

But I do not have a RAC, I have a Data Guard primary and Standby instance. Can I use a JDBC driver for this ?

Upvotes: 2

Views: 1749

Answers (1)

Dmitry Demin
Dmitry Demin

Reputation: 2113

We use the DataGuard in the following configuration. Connection string for jdbc.

  (DESCRIPTION =
    (FAILOVER=ON) 
    (LOAD_BALANCE=off)  
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.xx.yyy.88)(PORT = 1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.xx.yyy.89)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = D88.XXX.YYY.ZZZ)
      (FAILOVER_MODE=(TYPE=select)(METHOD=basic))
      (SERVER = DEDICATED)
    )
  )

The trigger creates a service when the database starts in the primary mode. Clients are connected by the name of the service, which is created in the trigger at the start of the database, and not by the default database name or service.

CREATE OR REPLACE TRIGGER sys.set_svc_name
 AFTER
  STARTUP
 ON DATABASE
DECLARE role VARCHAR(30);
BEGIN

SELECT Database_Role
INTO Role
FROM V$database;
IF Role = 'PRIMARY' THEN
EXECUTE IMMEDIATE 'alter system set service_names=''d88.XXX.YYY.ZZZ'' scope=memory'; END IF;

END;

Upvotes: 1

Related Questions