开发运行环境:JBoss EAP 6.2.0 + MySQL 5.6.19
1. 在[jboss_home]/modules目录下,创建目录:com/mysql/main
2. 在main目录下创建module.xml,内容如下:
<?xml version=“1.0” encoding=“UTF-8”?>
<module xmlns=“urn:jboss:module:1.1” name=“com.mysql”>
<resources>
<resource-root path=“mysql-connector-java-5.1.31-bin.jar”/>
</resources>
<dependencies>
<module name=“javax.api”/>
<module name=“javax.transaction.api”/>
</dependencies>
</module>
说明:MySQL的JDBC jar包可以从这里下载:http://dev.mysql.com/downloads/connector/j/。
3. 修改standalone.xml,其中datasources subsystem部分修改如下:
<subsystem xmlns=“urn:jboss:domain:datasources:1.1”>
<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;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<datasource jndi-name=“java:jboss/datasources/MysqlDSDemo” pool-name=“MysqlDSDemoPool” enabled=“true”>
<connection-url>jdbc:mysql://localhost:3306/demo</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>welcome1</password>
</security>
</datasource>
<drivers>
<driver name=“h2” module=“com.h2database.h2”>
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name=“mysql” module=“com.mysql”>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
4. 复制mysql-connector-java-5.1.31-bin.jar到main目录下
参考文献:
1. http://blog.csdn.net/kylinsoong/article/details/17042245
2. https://community.jboss.org/message/866635
1. 在[jboss_home]/modules目录下,创建目录:com/mysql/main
2. 在main目录下创建module.xml,内容如下:
<?xml version=“1.0” encoding=“UTF-8”?>
<module xmlns=“urn:jboss:module:1.1” name=“com.mysql”>
<resources>
<resource-root path=“mysql-connector-java-5.1.31-bin.jar”/>
</resources>
<dependencies>
<module name=“javax.api”/>
<module name=“javax.transaction.api”/>
</dependencies>
</module>
说明:MySQL的JDBC jar包可以从这里下载:http://dev.mysql.com/downloads/connector/j/。
3. 修改standalone.xml,其中datasources subsystem部分修改如下:
<subsystem xmlns=“urn:jboss:domain:datasources:1.1”>
<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;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>
<datasource jndi-name=“java:jboss/datasources/MysqlDSDemo” pool-name=“MysqlDSDemoPool” enabled=“true”>
<connection-url>jdbc:mysql://localhost:3306/demo</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>welcome1</password>
</security>
</datasource>
<drivers>
<driver name=“h2” module=“com.h2database.h2”>
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name=“mysql” module=“com.mysql”>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
</subsystem>
4. 复制mysql-connector-java-5.1.31-bin.jar到main目录下
参考文献:
1. http://blog.csdn.net/kylinsoong/article/details/17042245
2. https://community.jboss.org/message/866635
没有评论:
发表评论