As we all know, ORACLE provides services in several ways THIN connect, OCI Connect, Datalink and other data connection methods.
1.THIN Connect
In a single-instance scenario, the JDBC Connect STRING:JDBC:ORACLE:THIN:10.11.1.243:1521/ORCL
where IP 10.11.1.243:1521 server IP address and lisener listening port.
ORCL is the data service name.
In a RAC environment, JDBC Connect String:
jdbc:oracle:thin:@ (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)
(HOST = 10.11.1.231) (PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)
(HOST = 10.11.1.232) (PORT = 1521)) (load_balance = yes) (FAILOVER = ON) (Connect_data = (SERVER = dedicated) (service_name = racdb.its) (failover_mode= (TYPE = SELECT) (METHOD = BASIC) (retires = 20) (DELAY = 15))))
Where host is a configuration of two points of Lisener. The failover keyword is configured for failover. The load_balance opens the settings for load balancing.
SERVICE_NAME is the database instance name for the RAC system.
The following is the code for the Java system:
Java Demo
The configuration of the 2.OCI connection is also the usual TNS configuration
Single-instance scenario: very simple, no more cumbersome.
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = 10.11.1.243) (PORT = 1521))
(Connect_data =
(SERVER = dedicated)
(service_name = ORCL)
)
)
RAC Condition:
RACDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = racdb1-vip.its) (PORT = 1521))
(Connect_data =
(SERVER = dedicated)
(service_name = racdb)
(instance_name = RACDB1)
)
)
RACDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = racdb1-vip.its) (PORT = 1521))
(ADDRESS = (PROTOCOL = TCP) (HOST = racdb2-vip.its) (PORT = 1521))
(load_balance = yes)
(Connect_data =
(SERVER = dedicated)
(service_name = racdb)
)
)
LISTENERS_RACDB =
(Address_list =
(ADDRESS = (PROTOCOL = TCP) (HOST = racdb1-vip.its) (PORT = 1521))
(ADDRESS = (PROTOCOL = TCP) (HOST = racdb2-vip.its) (PORT = 1521))
)
Extproc_connection_data =
(DESCRIPTION =
(Address_list =
RACDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = racdb1-vip.its) (PORT = 1521))
(ADDRESS = (PROTOCOL = TCP) (HOST = racdb2-vip.its) (PORT = 1521))
(load_balance = yes)
(Connect_data =
(SERVER = dedicated)
(service_name = racdb)
)
)
LISTENERS_RACDB =
(Address_list =
(ADDRESS = (PROTOCOL = TCP) (HOST = racdb1-vip.its) (PORT = 1521)) (ADDRESS = (PROTOCOL = TCP) (HOST = racdb2-vip.its) (PORT = 1521))
)
Extproc_connection_data =
(DESCRIPTION = (Address_list =
(ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1))
)
(Connect_data =
(SID = Plsextproc)
(PRESENTATION = RO)
)
)
RACDB2 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = racdb2-vip.its) (PORT = 1521)) (Connect_data =
(SERVER = dedicated)
(service_name = racdb)
(instance_name = RACDB2)
)
)
Ext.: http://www.cnblogs.com/jerryxing/archive/2012/10/17/2728061.html
RAC JDBC Configuration