juicy0592 发表于 2008-12-26 17:54:14

JBoss配置mySQL数据源

说明:虽然此方法介绍的是如何在JBoss下配置mySQL数据源,其实按此方法,亦可配置Oracle数据源。
    唯一的不同,就是配置Oracle数据源时,需要配置修改的文件名是oracle-ds.xml。
    在jboss-4.2.2.GA\server\default\deploy下,新建一个mysql-ds.xml文件 (简便的方法,是从jboss-4.2.2.GA\docs\examples\jca文件夹下复制并修改mysql-ds.xml文件),大致修改至如下内容:
    view plaincopy to clipboardprint?
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- $Id: mysql-ds.xml,v 1.3.2.1 2004/12/01 11:46:00 schrouf Exp $ -->
    <!--Datasource config for MySQL using 3.0.9 available from:
    http://www.mysql.com/downloads/api-jdbc-stable.html
    -->
    <datasources>
      <local-tx-datasource>
      <jndi-name>mySQLtest</jndi-name>
      <connection-url>jdbc:mysql://localhost:3306/test</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>root</user-name>
      <password>root</password>
      <min-pool-size>5</min-pool-size>
      <max-pool-size>20</max-pool-size>
      <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</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
      <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
          -->
      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
      <metadata>
         <type-mapping>mySQL</type-mapping>
      </metadata>
      </local-tx-datasource>
    </datasources>
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- $Id: mysql-ds.xml,v 1.3.2.1 2004/12/01 11:46:00 schrouf Exp $ -->
    <!--Datasource config for MySQL using 3.0.9 available from:
    http://www.mysql.com/downloads/api-jdbc-stable.html
    -->
    <datasources>
      <local-tx-datasource>
      <jndi-name>mySQLtest</jndi-name>
      <connection-url>jdbc:mysql://localhost:3306/test</connection-url>
      <driver-class>com.mysql.jdbc.Driver</driver-class>
      <user-name>root</user-name>
      <password>root</password>
   <min-pool-size>5</min-pool-size>
   <max-pool-size>20</max-pool-size>
   
   
                  
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</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
      <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
          -->
      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
      <metadata>
         <type-mapping>mySQL</type-mapping>
      </metadata>
      </local-tx-datasource>
    </datasources>    上一页
页: [1]
查看完整版本: JBoss配置mySQL数据源