Feeds:
Posts
Comments

Archive for March, 2014

1. create a directory under jboss-as-xxx/modules/com/mysql/main

2. create a file named module.xml and put mysql connector file in the above created folder
jboss1

module.xml has the following content:

<?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.29.jar”/>
</resources>
<dependencies>
<module name=”javax.api”/>
</dependencies>
</module>

3. edit standalone.xml
jboss2

the edited datasources part looks like:

<datasources>
<datasource jndi-name=”java:jboss/datasources/ExampleDS” pool-name=”H2DS” enabled=”true” jta=”true” use-java-context=”true” use-ccm=”true”>
<connection-url>
jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
</connection-url>
<driver>
h2
</driver>
<pool>
<prefill>
false
</prefill>
<use-strict-min>
false
</use-strict-min>
<flush-strategy>
FailingConnectionOnly
</flush-strategy>
</pool>
<security>
<user-name>
sa
</user-name>
<password>
sa
</password>
</security>
</datasource>
<datasource jndi-name=”java:jboss/datasources/caijbosstest” pool-name=”mysqlDS” enabled=”true” jta=”true” use-java-context=”true” use-ccm=”true”>
<connection-url>
jdbc:mysql://localhost:3306/jbosstestdb?useUnicode=true&amp;characterEncoding=UTF-8
</connection-url>
<driver>
mysql
</driver>
<transaction-isolation>
TRANSACTION_READ_COMMITTED
</transaction-isolation>
<pool>
<min-pool-size>
10
</min-pool-size>
<max-pool-size>
100
</max-pool-size>
<prefill>
true
</prefill>
<use-strict-min>
false
</use-strict-min>
<flush-strategy>
FailingConnectionOnly
</flush-strategy>
</pool>
<security>
<user-name>
root
</user-name>
<password>
mypassword
</password>
</security>
<statement>
<prepared-statement-cache-size>
32
</prepared-statement-cache-size>
<share-prepared-statements/>
</statement>
</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”> <!– pay attention the module=”com.mysql”. The value should be consistent with the module name in module.xml–>
<xa-datasource-class>
com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
</xa-datasource-class>
</driver>
</drivers>
</datasources>

4. add this line “<jta-data-source>java:jboss/datasources/caijbosstest</jta-data-source>” to persistence.xml
jboss4

5. create a database named jbosstestdb:
mysql>create database jbosstestdb;

6.deploy project
jboss3

all database tables will be created automatically.

Read Full Post »