Chat with us, powered by LiveChat
Configuring OCI driver in JBoss EAP 6.4 for Oracle RAC

On this occasion, I will show what’s necessary to configure a Datasource in JBoss EAP 6 that uses an OCI driver.

Before that, let’s see what benefit we have when using the OCI type driver.

Commonly for connections to Oracle Database, the THIN type driver is used, either by direct connection or by means of a datasource. When using an OCI driver, certain additional benefits are obtained, for example, in case of failure of a database node in the Database in RAC mode, the communication between the Application and the Database is transparent, because OCI allows the use of TAF (Transparent Application Failover), thus the connection will be handled by another Database node without generating an error in the application or requesting that the application be logged in again.

The connection URL for OCI is simpler, for example:

jdbc:oracle:oci:@RINNOVODB

While the URL for THIN requires further parameterization:

jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)
(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.50) (PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.51) (PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=RINNOVODB)))

———————————————————-

Now let’s see how the OCI Driver is configured for JBoss:

Note: For example, it is understood that the Oracle Database client is installed with libraries and drivers for OCI and that JBoss EAP 6 is configured in domain mode and that the environment is a Red Hat EL.

1. The first thing to do is define certain environment variables in order that JBoss manages to find the necessary libraries for OCI, these variables can be defined either in a variable configuration file, in a terminal or include domain file. sh:

export JAVA_HOME=/jboss/java/jdk1.8.0_141
export JBOSS_HOME=/jboss/EAP-6.4.0/
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.1.0.2/client1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$JAVA_HOME/bin:$PATH:$ORACLE_HOME/bin

2. Then we must configure the tnsnames.ora file which must contain the alias referred to in the connection URL when creating the Datasource and using the OCI driver. This file is located in the Oracle database client in the path $ ORACLE_HOME / network / admin

As you can see in the image, the name of SCAN is being used as well as the balanced service.

3. Create the Datasource using the URL for OCI driver:

As can be seen in the image in the connection URL, the alias that is specified in the tnsnames.ora file is used, then if the Datasource connection is tested we will see that it is successful!

This is how the OCI driver is configured. 🙂

Comments are closed.