JBoss AS7 configuration MySQL data source

Source: Internet
Author: User
Tags flush min in domain jboss

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.