JDBC Server-Side Internal Driver for RAC
The Oracle JDBC server-side internal driver supports any Java code that runs
inside an Oracle database, such as Java stored procedures or Enterprise
JavaBeans, and must access the same database. This driver allows the Java
Virtual Machine (JVM) to communicate directly with the SQL engine. This allows
the server-side internal driver, JVM, database, KPRB (server-side) C library,
and SQL engine to all run within the same address space. When running code using
the server-side internal drivers within an Oracle RAC instance, it basically
runs in that particular database instance.
The middleware software layers now handle connectivity to the backend Oracle
database. Let us examine how some of the popular application servers handle
database connectivity and utilize the RAC database.
JDBC Oracle Call Interface Driver
The JDBC OCI
driver is a Type II driver for use with client-server Java applications. This
driver requires an Oracle client installation, and therefore is Oracle
platform-specific and not suitable for applets but great for RAC.
The JDBC Oracle
Call Interface (OCI) driver accesses Oracle and RAC-specific native code (that
is, non-Java) libraries on the client or middle tier, providing a richer set of
functions, and some performance boost compared to the JDBC Thin driver,
especially in RAC.
Using the JDBC
OCI driver allows the tnsnames.ora entry to be used. Therefore, it is a good
choice to access the Oracle RAC database with the full functionality of the TAF
configuration for load balancing and automatic failover.
While using the
JDBC OCI driver with RAC, the database can be specified with an Oracle Net
keyword-value pair. The Oracle Net keyword-value pair substitutes for the
tnsnames entry. The following example uses the same parameters as the preceding
example, but in the keyword-value format:
Connection conn = DriverManager.getConnection
(jdbc:oracle:oci:@MyHostString","scott","tiger");
Here is a JDBC connect string for connecting to Oracle via JDBC:
jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=yes)(ADDRESS=(PROTOCOL=TCP)(HOST=NODE1-VIP)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=NODE2-VIP)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MYRAC)))
See these related notes on using Real Application Clusters with JDBC: