【Java】JBoss7.1配置Oracle11g数据源,详细图解

1、将Oracle10g JDBC 驱动ojdbc6.jar包复制到JBOSS根目录\modules\com\oracle\main\文件夹下,其中(\oracle\main)文件目录不存在,需要新建。

在该目录下,创建文件module.xml,文件内容为:

<?xml version="1.0" encoding="UTF-8"?>  
  
<module xmlns="urn:jboss:module:1.0" name="com.oracle">  
<resources>   
    <!-- Insert resources here -->   
    <resource-root path="ojdbc6.jar"/>   
</resources>   
<dependencies>   
    <module name="javax.api"/>   
    <module name="javax.transaction.api"/>   
</dependencies>   
</module>

JBoss7.1配置Oracle11g数据源

2、修改配置文件:standalone\configuration\standalone.xml

<subsystem xmlns="urn:jboss:domain:datasources:1.0">  
    <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</connection-url>  
            <driver>h2</driver>  
            <security>  
                <user-name>sa</user-name>  
                <password>sa</password>  
            </security>  
        </datasource>  
        <datasource jta="true" jndi-name="java:jboss/OracleDS" pool-name="OracleDS" enabled="true" use-java-context="true" use-ccm="true">  
            <connection-url>jdbc:oracle:thin:@127.0.0.1:1521:orcl</connection-url>  
            <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>  
            <driver>oracle</driver>  
            <pool>  
                <min-pool-size>3</min-pool-size>  
                <max-pool-size>10</max-pool-size>  
                <prefill>true</prefill>  
                <use-strict-min>false</use-strict-min>  
                <flush-strategy>FailingConnectionOnly</flush-strategy>  
            </pool>  
            <security>  
                <user-name>scott</user-name>  
                <password>scott</password>  
            </security>  
            <validation>  
                <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>  
                <validate-on-match>false</validate-on-match>  
                <background-validation>false</background-validation>  
                <use-fast-fail>false</use-fast-fail>  
                <stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker"/>  
                <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>  
            </validation>  
        </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>

3、启动jboss,如果能启动成功,说明配置正确。启动Jboss之前,确保Oracle服务开启

JBoss7.1配置Oracle11g数据源


未经允许请勿转载:程序喵 » 【Java】JBoss7.1配置Oracle11g数据源,详细图解

点  赞 (0) 打  赏
分享到: