Friday, July 28, 2017

jboss eap 7 standalone setup Database

This note is for example guide for adding MySql, Oracle and mariadb for jboss eap 7 standalone.

MySql

1. download Mysql jdbc from this URL
https://dev.mysql.com/downloads/connector/j/

2. then at jboss directory, create this path
<jboss>/modules/com/mysql/main

3. upload the jdbc into the main directory and create module.xml.
copy and paste below into module.xml
change the word in red color to be same name as your driver name

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
  <resources>
    <resource-root path="mysql-connector-java-5.1.43-bin.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
  </dependencies>
</module>

4. change permission of the newly created file and directory to jboss

5. start jboss service

6. go to jboss bin directory and connect to jboss-cli
# ./jboss-cli.sh -c --controller=<server-IP>

7. input this to add Mysql driver
/subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource)

8. to edit the database connection details, i use its admin pages to add as it much more easy
at Browser, access to your admin pages by <server_ip>:9990
then follow the step below as screenshot

go to Configuration > Subsystems > Datasources > Non-Xa
and click add

Choose MySQL and click Next

Enter your JNDI name as below

go to Detected Driver and choose mysql

edit your connection URL according to your DB with the username and password

confirm details is correct and click Finish

Restart your jboss,
then back to admin > configuration again
then click your newly created Mysql and click test connection

you are done once test successful 


Oracle

1. download your oracle jdbc driver from this URL, choose the one match your DB version

2. create path for module/com/oracle/main

3. upload the driver to main folder and create module.xml
copy and paste below into module.xml
change the word in red color to be same name as your driver name

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

4. change ownership to jboss for newly create dir and file
# chown -R jboss;jboss module

5. start jboss and use jboss-cli to add the driver information
# ./jboss-cli.sh -c --controller=<server-IP>

6. copy paste below to setup the driver
/subsystem=datasources/jdbc-driver=oracle:add(driver-name=oracle,driver-module-name=com.oracle,driver-xa-datasource-class-name=oracle.jdbc.xa.client.OracleXADataSource)

7. to add DB details, go to admin site and add like Mysql example above. ( repeat step 8 for Mysql section)
just need to edit from mysql to oracle


MariaDB

1. download your oracle jdbc driver from this URL, choose the one match your DB version

2. create path for module/com/mariadb/main

3. upload the driver to main folder and create module.xml
copy and paste below into module.xml
change the word in red color to be same name as your driver name

<module xmlns="urn:jboss:module:1.1" name="com.mariadb">
    <resources>
        <resource-root path="mariadb-java-client-1.3.3.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>


4. change ownership to jboss for newly create dir and file
# chown -R jboss:jboss module

5. start jboss and use jboss-cli to add the driver information
# ./jboss-cli.sh -c --controller=<server-IP>

4. copy and paste to add the driver information
/subsystem=datasources/jdbc-driver=mariadb:add(driver-name=mariadb,driver-module-name=com.mariadb,driver-xa-datasource-class-name=org.mariadb.jdbc.MariaDbDataSource)

5. to add DB details, go to admin site and add like Mysql example above. (repeat step 8 at Mysql section)
just need to edit from mysql to oracle


MsSql

1. download your oracle jdbc driver from this URL, choose the one match your DB version

2. create path for module/com/microsoft/main

3. upload the driver to main folder and create module.xml
copy and paste below into module.xml
change the word in red color to be same name as your driver name

<module xmlns="urn:jboss:module:1.1" name="com.microsoft">
    <resources>
        <resource-root path=".jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
        <module name="javax.xml.bind.api"/>
    </dependencies>
</module>


4. change ownership to jboss for newly create dir and file
# chown -R jboss;jboss module

5. start jboss and use jboss-cli to add the driver information
# ./jboss-cli.sh -c --controller=<server-IP>

4. copy and paste to add the driver information
/subsystem=datasources/jdbc-driver=microsoft:add(driver-name=microsoft,driver-module-name=com.microsoft,driver-xa-datasource-class-name=com.microsoft.sqlserver.jdbc.SQLServerXADataSource)

5. to add DB details, go to admin site and add like Mysql example above. (repeat step 8 at Mysql section)
just need to edit from mysql to oracle

No comments:

Post a Comment