Sunday, 25 October 2015

Create Oracle DataSource And Install Oracle JDBC Driver in JBoss EAP6

1.Install a JDBC Driver


Before your application can connect to a JDBC datasource, your datasource vendor's JDBC drivers(ojdbc6.jar) need to be installed in a location where JBoss EAP 6 can use them. JBoss EAP 6 allows you to deploy these drivers like any other deployment.

I am going to deploy jdbc jar file via CLI

jdbc:oracle:thin@//192.168.1.12:1521/orcl
[jbossas@middleware bin]$ ./jboss-cli.sh --connect --controller=192.168.1.12:9999

[domain@192.168.1.12:9999 /] deploy /u01/app/oracle/product/11.1.0/db_1/jdbc/lib/ojdbc6.jar --server-groups=GB_server_group


Check jdbc jar file installed or not in admin console


Creating a DataSource from JBoss EAP Admin Console

1. Login to the Management Console.

   a. Select the Profiles tab from the top of the console
  • ·         Select the appropriate profile from the drop-down box in the top left.
  • ·         Expand the Subsystems menu on the left of the console.
  • ·         Select Connector → Datasources from the menu on the left of the console





Enter the new datasource attributes in the Create Datasource wizard and proceed with the Next button.

Select JDBC driver, which is already deployed. and click next button.
Enter the connection settings in the Create Datasource wizard and select the Done button.

And finally enable the datasource


The  datasource has been added to the server. It is now visible in either domain.xml file,

fallowing content has been added in the domain.xml

<datasource jta="false" jndi-name="java:/jdbc/GB_DATASOURCE" pool-name="GB_DATASOURCE" enabled="true" use-ccm="false">
                        <connection-url>jdbc:oracle:thin@//192.168.1.12:1521/orcl</connection-url>
                        <driver-class>oracle.jdbc.OracleDriver</driver-class>
                        <driver>ojdbc6.jar</driver>
                        <security>
                            <user-name>scott</user-name>
                            <password>tiger</password>
                        </security>
                        <validation>
                            <validate-on-match>false</validate-on-match>
                            <background-validation>false</background-validation>
                        </validation>
                        <statement>
                            <share-prepared-statements>false</share-prepared-statements>
                        </statement>
                    </datasource>


Management CLI

1. Launch the CLI tool and connect to your server.

2. Run the following command to create a non-XA datasource, configuring the variables as appropriate:

[domain@192.168.1.12:9999 /] data-source add --profile=full --name=KR_datasource --jndi-name=java:/jdbc/KR_DATASOURCE --driver-name=ojdbc6.jar --connection-url=jdbc:oracle:thin@//192.168.1.12:1521/orcl


3. Enable the datasource:

[domain@192.168.1.12:9999 /] data-source enable  --profile=full --name=KR_datasource

Check in admin console



No comments: