2014年7月16日星期三

EAP_005:配置Oracle数据源

开发运行环境:JBoss EAP 6.2.0 + Oracle Database XE 11gR2

1. 在[jboss_home]/modules目录下,创建目录:com/oracle/main

2. 在main目录下创建module.xml,内容如下:

 <?xml version=“1.0” encoding=“UTF-8”?>
<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>

3. 修改standalone.xml,其中datasources subsystem部分修改如下:

 <subsystem xmlns=“urn:jboss:domain:datasources:1.1”>
            <datasources>
                <datasource jndi-name=“java:jboss/datasources/ExampleDS” pool-name=“ExampleDS” enabled=“true” use-java-context=“true”>
                    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
                    <driver>h2</driver>
                    <security>
                        <user-name>sa</user-name>
                        <password>sa</password>
                    </security>
                </datasource>
                <datasource jndi-name=“java:jboss/datasources/OracleDSDemo” pool-name=“OracleDSDemoPool” enabled=“true”>
                    <connection-url>jdbc:oracle:thin:@10.66.192.109:1521:XE</connection-url>
                    <driver>oracle</driver>
                    <security>
                        <user-name>demo</user-name>
                        <password>demo</password>
                    </security>
                </datasource>
                <drivers>
                    <driver name=“h2” module=“com.h2database.h2”>
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                    <driver name=“oracle” module=“com.oracle”>
                        <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
                    </driver>
                </drivers>
            </datasources>
        </subsystem>

4. 复制ojdbc6.jar到main目录下

参考文献:
1. http://blog.csdn.net/kylinsoong/article/details/12340101

没有评论: