Looking for a JavaEE Architect or Potential Tech Co-Founder?
Please don't hesitate to contact me.

JBoss datasource configuration settings

The following are sample configurations for different database (it's in the file standalone.xml subsystem=datasources):
H2, postgresql, mysql
<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</connection-url>
  <driver>h2</driver>
  <security>
   <user-name>sa</user-name>
   <password>sa</password>
  </security>
 </datasource>
 <datasource jta="false" jndi-name="java:jboss/datasources/PostgreDatasource" pool-name="PostgrePool" enabled="true" use-java-context="true" use-ccm="false">
  <connection-url>jdbc:postgresql://localhost:5432/postgre</connection-url>
  <driver-class>org.postgresql.Driver</driver-class>
  <driver>postgresql</driver>
  <pool>
   <min-pool-size>2</min-pool-size>
   <max-pool-size>20</max-pool-size>
  </pool>
  <security>
   <user-name>postgre</user-name>
   <password>postgre</password>
  </security>
  <validation>
   <validate-on-match>false</validate-on-match>
   <background-validation>false</background-validation>
   <background-validation-millis>1</background-validation-millis>
  </validation>
  <statement>
   <prepared-statement-cache-size>10</prepared-statement-cache-size>
   <share-prepared-statements>false</share-prepared-statements>
  </statement>
 </datasource>
 <datasource jta="false" jndi-name="java:jboss/datasources/mysqlDataSource" pool-name="mysqlPool" enabled="true" use-java-context="true" use-ccm="false">
  <connection-url>jdbc:mysql://localhost:3306/mysql</connection-url>
  <driver-class>com.mysql.jdbc.Driver</driver-class>
  <driver>com.mysql</driver>
  <pool>
   <min-pool-size>2</min-pool-size>
   <max-pool-size>20</max-pool-size>
  </pool>
  <security>
   <user-name>mysql</user-name>
   <password>mysql</password>
  </security>
  <validation>
   <validate-on-match>false</validate-on-match>
   <background-validation>false</background-validation>
   <background-validation-millis>1</background-validation-millis>
  </validation>
  <statement>
   <prepared-statement-cache-size>10</prepared-statement-cache-size>
   <share-prepared-statements>false</share-prepared-statements>
  </statement>
 </datasource>
<datasource jndi-name="java:jboss/datasources/VmlaDS" pool-name="vmlaDS" enabled="true" use-java-context="true">
    <connection-url>jdbc:mysql://localhost:3306/vlma</connection-url>
    <driver>mysql</driver>
    <security>
        <user-name>vlma</user-name>
        <password>vlma</password>
    </security>
    <statement>
        <prepared-statement-cache-size>100</prepared-statement-cache-size>
        <share-prepared-statements>true</share-prepared-statements>
    </statement>
</datasource>
 <drivers>
<driver name="mysql" module="com.sql.mysql">
 <driver-class>com.mysql.jdbc.Driver</driver-class>
</driver>
  <driver name="h2" module="com.h2database.h2">
   <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
  </driver>
  <driver name="postgresql" module="org.postgresql">
   <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
  </driver>
   <driver name="com.mysql" module="com.mysql">
   <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
  </driver>
 </drivers>
</datasources>

Then add the following modules in: jboss-as-7.1.3.Final\modules
  1. postgresql
    1. create org/postgresql/main
    2. download and paste: postgresql-9.2-1002.jdbc4.jar
    3. create module.xml with these contents
    4. <?xml version="1.0" encoding="UTF-8"?>
      <module xmlns="urn:jboss:module:1.0" name="org.postgresql">
       <resources>
       <resource-root path="postgresql-9.2-1002.jdbc4.jar"/>
       </resources>
       <dependencies>
       <module name="javax.api"/>
       <module name="javax.transaction.api"/>
       </dependencies>
      </module>
  2. mysql
    1. create com/mysql/main
    2. download mysql-connector-java
    3. create module.xml with these contents
    4. <?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.21.jar"/>  
        </resources>  
        <dependencies>  
       <module name="javax.api"/>  
        </dependencies>  
      </module>  
      
JBoss datasource configuration settings JBoss datasource configuration settings Reviewed by Edward Legaspi on Friday, October 25, 2013 Rating: 5

No comments:

Powered by Blogger.