JBOSS配置JNDI数据源,适用4.0,5.0,6.0

25 篇文章 0 订阅
24 篇文章 0 订阅

1 在jboss\jboss-5.0.1.GA\lib 的目录里面放入应用需要的驱动JAR,比如ojdbc14.jar等

 

2在jboss-5.0.1.GA\docs\examples\jca目录下面查找自己想要连接数据库的配置文件的例子,复制出来修改。

 

 

<datasources>
  <local-tx-datasource>
    <jndi-name>jdbc/DataSource1</jndi-name>
    <connection-url>jdbc:oracle:thin:@192.168.56.10:1521:orcl10g</connection-url>
	<!--

		Here are a couple of the possible OCI configurations.
		For more information, see http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96654/toc.htm

	<connection-url>jdbc:oracle:oci:@youroracle-tns-name</connection-url>
		or
	<connection-url>jdbc:oracle:oci:@(description=(address=(host=youroraclehost)(protocol=tcp)(port=1521))(connect_data=(SERVICE_NAME=yourservicename)))</connection-url>

		Clearly, its better to have TNS set up properly.
	 -->
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <user-name>testbrook</user-name>
    <password>testbrook</password>
    <!-- Uses th pingDatabase method to check a connection is still valid before handing it out from the pool -->
    <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
    <!-- Checks the Oracle error codes and messages for fatal errors -->
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
        <!-- sql to call when connection is created
        <new-connection-sql>some arbitrary sql</new-connection-sql>
        -->

        <!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConnectionChecker is prefered
        <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
        -->

      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
      <metadata>
         <type-mapping>Oracle10g</type-mapping>
      </metadata>
  </local-tx-datasource>
 <local-tx-datasource>
    <jndi-name>jdbc/DataSource2</jndi-name>
    <connection-url>jdbc:oracle:thin:@192.168.56.1:1521:orcl10g</connection-url>
	<!--

		Here are a couple of the possible OCI configurations.
		For more information, see http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96654/toc.htm

	<connection-url>jdbc:oracle:oci:@youroracle-tns-name</connection-url>
		or
	<connection-url>jdbc:oracle:oci:@(description=(address=(host=youroraclehost)(protocol=tcp)(port=1521))(connect_data=(SERVICE_NAME=yourservicename)))</connection-url>

		Clearly, its better to have TNS set up properly.
	 -->
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <user-name>testbrook</user-name>
    <password>testbrook</password>
    <!-- Uses th pingDatabase method to check a connection is still valid before handing it out from the pool -->
    <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
    <!-- Checks the Oracle error codes and messages for fatal errors -->
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
        <!-- sql to call when connection is created
        <new-connection-sql>some arbitrary sql</new-connection-sql>
        -->

        <!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConnectionChecker is prefered
        <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
        -->

      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
      <metadata>
         <type-mapping>Oracle10g</type-mapping>
      </metadata>
  </local-tx-datasource>
</datasources>

 3把修改好的配置文件放入 \jboss\jboss-5.0.1.GA\server\default\deploy 目录里面

 

 4 把应用的WAR包放入jboss\jboss-5.0.1.GA\server\default\deploy里面

 

 5重启JBOSS,访问应用

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值