Search This Blog

Thursday, November 08, 2018

How to add Datasource to JBoss EAP 6 / WildFly 8

You can add datasource element to standalone.xml or the domain.xml file of JBoss EAP 6 / WildFly 8. The following is the example of MySQL datasource element. You can use same parameter to add the datasource from management console.


<datasource jta="true" jndi-name="java:/YourDatasourceName" pool-name="YourDatasourceName" enabled="true" use-ccm="true">
 <connection-url>jdbc:mysql://localhost:3306/YourDataBaseName</connection-url>
 <!-- You don't need driver class for JDBC 4 compliance Driver -->
<driver-class>com.mysql.jdbc.Driver</driver-class>  <driver>mysql-connector-java-5.1.33-bin.jar</driver>
<!-- <driver>mysql-connector-java-5.1.33-bin.jar_com.mysql.jdbc.Driver_5_1</driver> -->
 <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
 <pool>
   <min-pool-size>100</min-pool-size>
   <max-pool-size>200</max-pool-size>
 </pool>
 <security>
   <user-name>USERID</user-name>
   <password>PASSWORD</password>
 </security>
 <statement>
   <prepared-statement-cache-size>100</prepared-statement-cache-size>
   <share-prepared-statements/>
 </statement>
</datasource>


Connection URL:The JDBC driver connection URL
New Connection Sql:Specifies an SQL statement to execute whenever a connection is added to the connection pool
Transaction Isolation:Set the java.sql.Connection transaction isolation level. Valid values are: TRANSACTION_READ_UNCOMMITTED, TRANSACTION_READ_COMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE and TRANSACTION_NONE
Use JTA?:Enable JTA integration
Use CCM?:Enable the use of a cached connection manager

See also:

How to install JDBC driver to JBoss EAP 6 / WildFly 8