JBOSS EAP 6 Series three configuration (driver) of Oracle, MySQL data sources-recognize the use of modules

Source: Internet
Author: User
Tags create directory tag name jboss

This article describes how Oracle data sources are configured in JBoss EAP 6.2. Combining with the new features of JBoss EAP 6.2, this paper introduces the features of the JBoss Module declaration container.

Module Declaration Container : JBOSS EAP no longer has the concept of lib, everything is module. Either the Lib of the system call, the user-compiled Lib, or the third-party lib that the application refers to are built in a modular way, and the specific module is declared where it is used.

The configuration of the data source is described in three steps:
    1. Building a database driver into a module within JBoss
    2. Loading the driver module for the JBoss container
    3. Configure a data source for a JBoss container



1. Build the database driver into a module in JBossThe data source driver is the interface that Java obtains to connect with the data source, which can be understood as the lib of the system call mentioned above, so we need to build the data source driver into a JBoss module and build two steps:
    1. Place the resource in the correct location: under the%jboss_eap_home%/modules directory
    2. To configure a resource as a JBoss module: writing the Module.xml file

Next, take Oracle as an example to build an Oracle driver module
1. Create directory%jboss_eap_home%/modules/com/oracle/main/, store Oracle driver: Ojdbc14.jar (for Oracle 10g)
2. Create the Moduel.xml configuration file in main
<?xmlversion= "1.0" encoding= "UTF-8"? ><module xmlns= "urn:jboss:module:1.0" name= "com.oracle" >                < resources>                                <resource-rootpath= "Ojdbc14.jar"/>                </resources>                <dependencies>                                <modulename= "Javax.api"/>                                <modulename= "Javax.transaction.api"/>                </dependencies> </module>


which
<module> indicates the name of this module com.oracle for other modules to be dependent;
<resource> Specify the resource name of the module, and the resource should be in the same folder as Module.xml;
<dependencies> indicates which modules the module relies on, such as the two modules indicated in Module.xml, which are implemented as a mock Oracle data source module, which can be found under%jboss_eap_home%/modules:
Jboss-eap-6.1\modules\system\layers\base\javax\api\mainjboss-eap-6.1\modules\system\layers\base\javax\ Transaction\api\main




"Module Configuration Small extension"
    • The resource can be a jar package or a folder, such as the system default configuration: Jboss-eap-6.2\modules\system\layers\base\sun\jdk\main
    • Strictly speaking, as long as the configuration files and resources together, as long as the modules directory, the exact location of the matter, but it is important to note that the <module> tag name to match the directory under the modules of the resource.
    • Module.xml can map other existing module, such as system default configuration: jboss-eap-6.2\modules\system\layers\base\org\apache\commons\logging\main\ Module.xml

2. Load drive module for JBoss containerThe configuration file for the JBOSS container is in%jboss_eap_home%\standalone\configuration, and the configuration file for the cluster is E:\server\jboss-eap-6.1\domain\ In the configuration
we mainly look at the%jboss_eap_home%\standalone\configuration\standalone.xml of a single host


Open Standalone.xml The first thing you see is:


 
  <extensions> <extension module= "Org.jboss.as.clustering.infinispan"/> <extension module= "or G.jboss.as.connector "/> <extension module=" Org.jboss.as.deployment-scanner "/> <extension module= "Org.jboss.as.ee"/> <extension module= "org.jboss.as.ejb3"/> <extension module= "Org.jboss.as.jaxr S "/> <extension module=" org.jboss.as.jdr "/> <extension module=" org.jboss.as.jmx "/> &lt ; extension module= "Org.jboss.as.jpa"/> <extension module= "org.jboss.as.jsf"/> <extension module= "Org.jboss.as.logging"/> <extension module= "Org.jboss.as.mail"/> <extension module= "org.jboss.as . naming "/> <extension module=" Org.jboss.as.pojo "/> <extension module=" org.jboss.as.remoting "/&gt        ;  <extension module= "Org.jboss.as.sar"/> <extension module= "org.jboss.as.security"/> <extension Module= "Org.jbOss.as.threads "/> <extension module=" org.jboss.as.transactions "/> <extension module=" org.jboss.a S.web "/> <extension module=" org.jboss.as.webservices "/> <extension module=" Org.jboss.as.weld "/&G    T </extensions>



Each of these is module modules, which correspond to the same resources as the data source drivers configured in the first step, standalone.xml the container to indicate and load the default resources that need to be used.


simply put, there are four parts of standalone:
    • Extensions: Loading the module that the container uses by default
    • Manangement: Configuring Container Management
    • Profile: The subsystem configuration used by the container
    • Interfaces: Configuration of the container's external accessibility
    • Socket-binding-group: Binding the service in the container to the machine port
in the following article, we will go back to the common configuration of standalone configuration files, which is not too much to repeat.


The data source belongs to the subsystem of the container, so it is loaded under profile <subsystem xmlns= "urn:jboss:domain:datasources:1.1" > sub-Tags
<datasource> Configure the data source to use in the third step
<drivers> Configuring data source Drivers


because you do not know what data source to use, there is no module in the extensions that was previously loaded by default that specifies this data source-driven module. We need to load in <drivers>, oracleds as an example to add the following tags,
<driver name= "Oracle" module= "Com.oracle" ><driver-class>oracle.jdbc.oracledriver</driver-class > <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class> </driver >


The module attribute in the,<driver> tag is the name in the Module.xml that we created in the first step:
<module xmlns= "urn:jboss:module:1.0" name= "Com.oracle" >

* Here is actually a two driver, one is the general DataSource one is xa-datasource,xa-datasource in this article at the end of a brief supplement.

3. Configure the data source for the JBoss containerThe last step is to configure the data source, that is, the <datasource> tag, because it is the base configuration, so the code directly:

 <datasource jta= "true" Jndi-name= "Java:jboss/datasource/oracleds" pool-name= "Oracleds" enabled= "true" use-ccm= "                    False "> <connection-url>jdbc:oracle:thin:@192.168.*.*:1521:orcl</connection-url> <driver-class>oracle.jdbc.OracleDriver</driver-class> <driver>oracle</                        Driver> <security> <user-name>yaoyu</user-name> <password>yaoyu</password> </security> <validation&                        Gt <validate-on-match>false</validate-on-match> <background-validation>false</bac                        Kground-validation> </validation> <statement> <share-prepared-statements>false</share-prepared-statements> </statement> </da TasourcE>  

          


Where part of <driver> corresponds to the name of <driver> in the second step

<driver name= "Oracle" module= "Com.oracle" >


Oracle's data sources are well-equipped.


test, you can open web-console in the DataSource to test connection to try to connect to the data source.


* Extension: Configuration of Xa-datasource

interface can see DataSource and Xa-datasource, this is actually two kinds of data source configuration, XA is "globle Transaction" meaning, more specific reference http://www.blogjava.net/ Jeffery001/archive/2010/08/30/330054.html.

need to match Xa-ds, the first step to configure the driver module is the same jar, the difference is in the second step of the <driver> added Xa-datasource, In the third step, configure

as follows

<span style= "FONT-SIZE:18PX;" ><datasources> <xa-datasource jndi-name= "java:/jcoracleds" pool-name= "jcoracleds" > <driver> oracle</driver> <xa-datasource-property name= "URL" >jdbc:oracle:oci8: @tc </xa-datasourceproperty > <security> <user-name>admin</user-name> &LT;PASSWORD&GT;ADMIN123&L t;/password> </security> <xa-pool> <is-same-rm-override>false</is-same-rm-ove rride> <no-tx-separate-pools/> </xa-pool> <validation> <valid-con Nection-checker classname= "Org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker" ></ valid-connection-checker> <stale-connection-checker classname= "Org.jboss.jca.adapters.jdbc.extensions.ora Cle. Oraclestaleconnectionchecker "></stale-connection-checker> <exception-sorter classname=" ORG.JBOSS.JC A.adaPters.jdbc.extensions.oracle.OracleExceptionSorter "></exception-sorter> </validation> </xa-dat asource> <drivers> <driver name= "Oracle" module= "com. Oracle" > &LT;XA-DATASOURCE-CLASS&GT;ORACLE.J Dbc.xa.client.oraclexadatasource</xadatasource-class> </driver> </drivers></datasources> </span>


Summary

This article describes the configuration of the Oracle data source in JBoss EAP 6.1 (Configuration for JBoss AS7) in 3 steps:

1. Build the database driver into a module in JBoss
2. Load drive module for JBoss container
3. Configure the data source for the JBoss container

In addition to the configuration is primarily to JBoss EAP 6. 2 A simple understanding of the feature of the "Modular Declaration container"

JBOSS EAP 6 Series three configuration (driver) of Oracle, MySQL data sources-recognize the use of modules

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.