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

How to use mariadb and liquibase together with maven on jboss

First you must define the needed dependency in your pom file.
<profile>
 <id>mariadb</id>
 <activation>
  <property>
   <name>env</name>
   <value>mariadb</value>
  </property>
 </activation>
 <properties>
  <db.driver>org.mariadb.jdbc.Driver</db.driver>
  <db.url>jdbc:mariadb://localhost:3306/mariadb</db.url>
  <db.username>mariadb</db.username>
  <db.password>mariadb</db.password>
 </properties>
 <dependencies>
  <!-- Dependency for liquibase plugin -->
  <dependency>
   <groupId>org.mariadb.jdbc</groupId>
   <artifactId>mariadb-java-client</artifactId>
   <version>1.5.4</version>
  </dependency>   
 </dependencies>
</profile>
Then we need to configure jboss datasource
<datasource jta="true"
     jndi-name="java:jboss/datasources/MariaDBAdminDatasource" pool-name="MariaDBMariadb"
     enabled="true" use-java-context="true" use-ccm="false">
 <connection-url>jdbc:mariadb://127.0.0.1:3306/MariaDB</connection-url>
 <driver-class>org.mariadb.jdbc.Driver</driver-class>
 <driver>mariadb-driver</driver>
 <pool>
  <min-pool-size>2</min-pool-size>
  <max-pool-size>20</max-pool-size>
 </pool>
 <security>
  <user-name>MariaDB</user-name>
  <password>MariaDB</password>
 </security>
 <validation>
  <validate-on-match>true</validate-on-match>
  <background-validation>true</background-validation>
  <check-valid-connection-sql>select 1</check-valid-connection-sql>
 </validation>
 <statement>
  <prepared-statement-cache-size>10</prepared-statement-cache-size>
  <share-prepared-statements>false</share-prepared-statements>
 </statement>
</datasource>

<drivers>
 <driver name="mariadb-driver" module="org.mariadb">
  <xa-datasource-class>org.mariadb.jdbc.MySQLDataSource</xa-datasource-class>
 </driver>
</drivers>
And finally inside jboss modules folder we need to create a new folder: org\mariadb\main with mariadb-java-client-1.5.4.jar and module.xml. Content of module.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.mariadb">
  <resources>
    <resource-root path="mariadb-java-client-1.5.4.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
    <module name="javax.transaction.api"/>
  </dependencies>
</module>

How to use mariadb and liquibase together with maven on jboss How to use mariadb and liquibase together with maven on jboss Reviewed by Edward Legaspi on Friday, February 10, 2017 Rating: 5

No comments:

Powered by Blogger.