AS7 The default data source is H2, although H2 convenient, but the general production environment are MySQL, ORACLE, SQL Server mostly, this article describes how to configure the MySQL data source AS7.
According to the JBoss community documentation, configuring a new data source is roughly two steps. The description is as follows:
Add JDBC Driver file
Add the following directory structure and files under the Jboss_home/modules directory:
Jboss_home
+-modules
+-com
+-mysql +-
main
+-
module.xml Mysql-connector-java-5.1.15.jar (mysql jdbc driver jar file, version depending on their case
)
+- Mysql-connector-java-5.1.15.jar.index
The contents of Module.xml are as follows:
<?xml version= "1.0" encoding= "UTF-8"?> <module xmlns=
"urn:jboss:module:1.0" name= "Com.mysql" >
<resources>
<resource-root path= "Mysql-connector-java-5.1.15.jar"/>
</resources >
<dependencies>
<module name= "Javax.api"/>
</dependencies>
</ Module>
The contents of Mysql-connector-java-5.1.15.jar.index are as follows:
Meta-inf
meta-inf/services com
com/mysql com/mysql/jdbc
com/mysql/jdbc/configs
com/mysql/jdbc/ Exceptions
com/mysql/jdbc/exceptions/jdbc4
com/mysql/jdbc/interceptors
COM/MYSQL/JDBC/JDBC2
Com/mysql/jdbc/jdbc2/optional
com/mysql/jdbc/jmx
com/mysql/jdbc/log
Com/mysql/jdbc/profiler
com/mysql/jdbc/util
org
org/gjt
org/gjt/mm
org/gjt/mm/mysql
Add Server data Source configuration
AS7 start into two forms, one is in domain form, one is standalone, here we choose Standalone. Open the Jboss_home\standalone\configuration\standalone.xml file and add the following <datasources> below:
<datasource jndi-name= "Java:jboss/datasources/mysqlds" pool-name= "Mysqlds" enabled= "true" Jta= "true" Use-java-context= "true" use-ccm= "true" > <connection-url> jdbc:mysql://192.168.1.150:330
6/hospital? Createdatabaseifnotexist=true&useunicode=true&characterencoding=utf-8 </connection-url> &L t;driver> com.mysql </driver> <transaction-isolation> T ransaction_read_committed </transaction-isolation> <pool> <min-pool-size
> </min-pool-size> <max-pool-size>
</max-pool-size> <prefill> True
</prefill> <use-strict-min> False
</use-strict-min> <flush-strategy> failingconnectiononly </flush-strategy&
Gt
</pool> <security> <user-name> Runes
</user-name> <password> runes </password>
</security> <statement> <prepared-statement-cache-size> </prepared-statement-cache-size> </statement> </datasource>