Version 2

    This article will show you how to connect to Oracle using OCI driver instead of the THIN driver. OCI Driver is a Type 2 driver which uses Oracle's OCI layer thus depends upon the native libraries. Where as a THIN driver is Type 4 driver does not require any native libraries. The below instructions are for a Linux machine.

     

    • Before you begin you need to download the Oracle OCI JDBC driver and its .so files from Oracle Technology Network (OTN), here is a link for it Oracle Instant Client Downloads
    • The download is called "instaclient", unzip the contents into a directory called "~/oracle". The directory will have something like "~/oracle/instaclient_12_1"
    • Now you can either do Option 1 or Option 2. Option 2 is recommended.

     

    Option 1:

    • Open a terminal window and add "export LD_LIBRARY_PATH=~/oracle/instaclient_12_1"
    • Create a module directory in WildFly for deploying your Oracle JDBC Driver.  Create directory "<WildFly>/modules/system/layers/dv/com/oracle/main" and create file called "module.xml" with following contents.

     

    <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.0" name="com.oracle">
        <resources>
            <resource-root path="ojdbc6.jar" />
        </resources>
       <dependencies> 
        <module name="javax.api"/> 
       </dependencies>    
    </module>
    
    

     

    • Copy the ojdbc6.jar from "~/oracle/instaclient_12_1" directory into "<WildFly>/modules/system/layers/dv/com/oracle/main" directory.
    • Option 1 ends here, follow steps after Option 2.


    Option 2:

    • Create a module directory in WildFly for deploying your Oracle JDBC Driver.  Create directory "<WildFly>/modules/system/layers/dv/com/oracle/main" and create file called "module.xml" with following contents.

     

    
    <?xml version="1.0" encoding="UTF-8"?>
    <module xmlns="urn:jboss:module:1.0" name="com.oracle">
        <resources>
            <resource-root path="ojdbc6.jar" />
           <resource-root path="lib"/>
        </resources>
       <dependencies> 
        <module name="javax.api"/> 
       </dependencies>    
    </module>
    


    • create directory "<wildfly>/modules/system/layers/dv/com/oracle/main/lib/linux-x86_64" and then copy all the "*.so" files from "~/oracle/instaclient_12_1" into this directory. Note if you are working with Windows the directory name will be "<wildfly>/modules/system/layers/dv/com/oracle/main/lib/win". For more information on other platforms, see Native Libraries - JBoss Modules - Project Documentation Editor
    • Copy the ojdbc6.jar from "~/oracle/instaclient_12_1" directory into "<WildFly>/modules/system/layers/dv/com/oracle/main" directory.
    • Option 2 ends here, follow steps underneath.


    Now edit the standalone.xml file in "<WildFly>/standalone/configuration" directory and add following fragments to "datasources" subsystem in appropriate places.

     

    Under <drivers> element

    <driver name="oracle" module="com.oracle">
         <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    </driver>
    
    

     

    Under <datasources> element

    <datasource jndi-name="java:/OracleDS" pool-name="OracleDS" enabled="true" use-java-context="true">
        <connection-url>jdbc:oracle:oci:@//{hostname}:1521/{servicename}</connection-url>
        <driver>oracle</driver>
        <security>
            <user-name>{user}</user-name>
            <password>{password}</password>
        </security>
    </datasource>
    
    

     

     

    Now, start the WildFly server from same terminal where you set the $LD_LIBRARY_PATH. (Only needed if you choose Option 1)

     

    In case you are using Teiid, you can use a XML based VDB like below to create a VDB and connect and execute queries against it.

     

    <vdb name="oracle" version="1">
        <model visible="true" name="Parts">
            <property name="importer.schemaPattern" value="{your-schema-name}"/>        
            <source name="Parts" translator-name="oracle" connection-jndi-name="java:/OracleDS"/>          
        </model>
    </vdb>
    
    

     

     

    Hope this has been useful.

     

    Enjoy.

     

    Ramesh..