Connection information for primary and alternate servers can be specified using either one of the following methods:
Connection URL through the JDBC Driver Manager
JDBC data source
For example, the following connection URL for the Oracle driver specifies connection information for the primary and alternate servers using a connection URL:
is the part of the connection URL that specifies connection information for the primary server. Alternate servers are specified using the AlternateServers property. For example:
In this example, connection information for the primary server is specified using the ServerName, PortNumber, and ServiceName properties. Connection information for alternate servers is specified using the AlternateServers property.
For information about specifying connection information for primary and alternate servers using a tnsnames.ora file, see "Using tnsnames.ora files".
The value of the AlternateServers property is a string that has the format:
servername1 is the server name of the first alternate database server, servername2 is the server name of the second alternate database server, and so on. The server name is required for each alternate server entry.
port1 is the port number on which the first alternate database server is listening, port2 is the port number on which the second alternate database server is listening, and so on. The port number is optional for each alternate server entry. If unspecified, the port number specified for the primary server is used. If a port number is unspecified for the primary server, a default port number of 1521 is used.
property=value is one of the following connection properties: ServiceName or SID. These connection properties are optional for each alternate server entry and are mutually exclusive. For example:
If you do not specify an optional connection property in an alternate server entry, the connection to that alternate server uses the property specified for the primary server. For example, if you specify SID=ORCL for the primary server and do not specify a SID in the alternate server entry as shown in the following URL, the driver uses the SID specified for the primary server and tries to connect to the ORCL database on the alternate server: