http://blog.csdn.net/jyy208/article/details/5820893 jboss使用xml文件配置数据源,在JBOSS_HOME/docs/examples/jca文件夹下可以找到各种数据库的数据源配置文件的实例,jboss数据源配置文件的文件名格式是:*-ds.xml,文件中的内容如下(mysql):
[xhtml] view plaincopy
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- See http://www.jboss.org/community/wiki/Multiple1PC for information about local-tx-datasource -->
- <!-- $Id: mysql-ds.xml 88948 2009-05-15 14:09:08Z jesper.pedersen $ -->
- <!-- 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>MySqlDS</jndi-name>
- <connection-url>jdbc:mysql://mysql-hostname:3306/jbossdb</connection-url>
- <driver-class>com.mysql.jdbc.Driver</driver-class>
- <user-name>x</user-name>
- <password>y</password>
- <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
- <!-- should only be used on drivers after 3.22.1 with "ping" support
- <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-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 - MySQLValidConnectionChecker is preferred for newer drivers
- <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>
将配置文件修改好再放到JBOSS_HOME/server/default/deploy文件夹下,再将数据库驱动包拷贝到JBOSS_HOME/server/default/lib文件夹下,最后重启jboss,数据源就配置好了!
更多文章:
Jboss数据源的配置-http://www.blogjava.net/toby/archive/2009/03/24/261768.html
时间: 2024-11-04 12:31:54