jboss4 配置多个oracle数据源源的方法,在一个应用中引用两个oracle的数据源:jdbc/salesmgmt,jdbc/homelink
配置方法如下:
1 将%JBOSS_HOME%\docs\examples\jca\oracle-ds.xml copy
到%JBOSS_HOME%\server\default\deploy目录下
2 打开oracle-ds.xml,做如下编辑
A 修改jndi名字 <jndi-name> jdbc/salesmgmt </jndi-name>
B 修改db url <connection-url>jdbc:oracle:thin:@172.16.5.61:1521:hldata</connection-url>
C 修改驱动 <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
D 修改用户名和密码
<user-name>noble</user-name>
<password>yyaccp</password>
3 将Oracle驱动程序,copy到 %JBOSS_HOME%\ server\default\lib目录下
4 完成 jdbc/salesmgmt 的Oracle数据源配置,另一个数据源配置同上,
最后配置好的数据源文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/salesmgmt</jndi-name>
<use-java-context>true</use-java-context>
<connection-url>jdbc:oracle:thin:@172.16.5.61:1521:hldata</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>salesmgmt_oper</user-name>
<password>SALESMGMT_oper</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</local-tx-datasource>
<local-tx-datasource>
<jndi-name>jdbc/homelink</jndi-name>
<use-java-context>true</use-java-context>
<connection-url>jdbc:oracle:thin:@172.16.5.61:1521:hldata</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>salesmgmt_oper</user-name>
<password>SALESMGMT_oper</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>