JBoss Wildfly 14 – Java 11 – how to add / configure a datasource Oracle 11G

How to setup the oracle driver or add a datasource oracle in your server jboss wildfly ? here , in the following lines, you can find an example of configuration you can apply :

Module configuration

In your directory
path-to-wildfly\wildfly-14.0.1.Final\modules\system\layers\base\com\oracle\main

add this 2 file :

1) the jar ojdbc7.jar from oracle.

2) create a file module.xml with this content :

 

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

 

Update standalone.xml

Assuming you are using the standalone mode, update the file standalone.xml in the directory :
path-to-wildfly\wildfly-14.0.1.Final\standalone\configuration

After the tag <\extensions> add the following line :

<paths>
<path name= »oraclejar » path= »mypathtowilfly\wildfly-14.0.1.Final\modules\system\layers\base\com\oracle\main »/<
</paths>example :
<paths>
<path name= »oraclejar » path= »D:\Server\wildfly-14.0.1.Final\wildfly-14.0.1.Final\modules\system\layers\base\com\oracle\main »/<
</paths>

In the part <subsystem xmlns= »urn:jboss:domain:datasources:5.0″> and inside the tag <datasources> , add the following lines :

 

<datasource jndi-name= »java:jboss/datasources/OracleDS » pool-name= »OracleDS » enabled= »true »>
<connection-url>jdbc:oracle:thin:@IPofYourServer:1521:ora11g</connection-url>
<driver>oracle</driver>
<pool>
<min-pool-size>1</min-pool-size>
<max-pool-size>5</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>your-database-user</user-name>
<password>your-database-password</password>
</security>
</datasource>

don’t forget to modify the term IPofYourServer with your own server IP where you host the oracle database and to update the user name [your-database-user] and the password of the database user [your-database-password]

and inside the tag <drivers> :

 

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

Find the line : <subsystem xmlns= »urn:jboss:domain:ee:4.0″>

and add under the following lines :

<global-modules>
<module name= »com.oracle »/>
</global-modules>

Tips : in case you have a port conflict when running jboss on the port 8080 with the oracle database, you can change the port in the standalone.xml file , find the line <socket-binding-group

and edit the following line, by example if you want set up the port to 8081 :

<socket-binding name= »http » port= »${jboss.http.port:8081} »/>

Laisser un commentaire