Oracle Data source configuration in Jboss

What is Data Source ?

Data Source allow to you to manage a pool of connection to a database
Data Source is handle to which database you want to connect , it is a communication between database and client or end-user

Steps for creating datasource in Jboss:
  1. Check prerequisites for drivers according to database and its version.
  2. For oracle DB 11g, we need ojdbc6.jar driver.download it from here--> click
  3. We need to create a module.xml file to defile driver module for the oracle driver.
  4. The module.xml will be

<module xmlns="urn:jboss:module:1.1" name="com.oracle.jdbc">
  <resources>
    <resource-root path="ojdbc6.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
    <module name="javax.servlet.api" optional="true"/>
  </dependencies>
</module>


  1. Create below directories in JBOSS_HOME:
         JBOSS-HOME/modules/com/oracle/jdbc/main

      2. Keep the ojdbc6.jar and module.xml file in
      
        /jboss-HOME/modules/com/oracle/jdbc/main
    
       3. We need to add datasource in standalone.xml file.

<datasources>
  <datasource jndi-name="java:/OracleDS" pool-name="OracleDS">
    <connection-url>jdbc:oracle:thin:@localhost:1521:XE</connection-url>
    <driver>oracle</driver>
    <security>
      <user-name>admin</user-name>
      <password>admin</password>
    </security>
  </datasource>
  <drivers>
    <driver name="oracle" module="com.oracle">
    </driver>
  </drivers>
</datasources>

Start the jboss EAP server.

Go to Configuratiosà connectorà datasources àAdd


Enter Name and JNDI name:
What is JNDI ?
Java Naming Directory Interface Service is used to register the resource hosted by server's
JNDI gives unique name for every server
It is implements on the top of CORBA (Common Request Broker Architecture)

It will automatically load defined driver which details are added in standalone.xml file.

Now its a final step:
Insert your connection URL which consist of database IP or scan_name, port on which database is running and SID of the database.
If you are unaware of database SID the do this:
echo $ORACLE_SID :- the result will be SID of your current database.

Enter current DB credentials:
and after all, Test Connection. If you have done all right, then test connection will successful.

Congratulations...
For first time datasource will be in disable state. You have to enable it manually.

Voila...


Thank you...
If you have any doubts , queries feel free to comment.



Comments