Bookmark this page

Guided Exercise: Configuring an XA Datasource

Create, configure, and test a MariaDB XA data source.

Resources
Files: /home/student/AD248/labs/datasources-xa
Application URL: N/A

Outcomes

You should be able to create and test an XA data source based on the MariaDB driver.

Before beginning the guided exercise, run the following command to prepare the environment:

[student@workstation ~]$ lab start datasources-xa

Instructions

  1. Start the standalone instance of JBoss EAP by running the following command, which uses /home/student/AD248/labs/datasources-xa/standalone as the base directory:

    [student@workstation ~]$ cd /opt/jboss-eap-7.4/bin
    [student@workstation bin]$ ./standalone.sh \
    -Djboss.server.base.dir=/home/student/AD248/labs/datasources-xa/standalone
  2. Configure the XA JDBC driver.

    1. Open a new terminal window, and run the following commands to connect to JBoss EAP by using the management CLI:

      [student@workstation ~]$ cd /opt/jboss-eap-7.4/bin
      [student@workstation bin]$ ./jboss-cli.sh --connect
    2. Use the management to create the datasource with the following configuration:

      • Datasource name: MariaDBXADS

      • JNDI name: java:jboss/datasources/MariaDBXADS

      • driver name: mariadb

      • username: developer

      • password: redhat123

      • XA datasource property: Url=jdbc:mariadb://localhost:3306/lab_db

        Run the following management CLI command to create the datasource:

      [standalone@localhost:9990] xa-data-source add --name=MariaDBXADS \
      --jndi-name=java:jboss/MariaDBXADS --driver-name=mariadb \
      --user-name=developer --password=redhat123 \
      --xa-datasource-properties={"Url"=>"jdbc:mariadb://localhost:3306/lab_db"}

      Note that this course uses the version 3.2 for the MariaDB JDBC driver which requires the Url datasource XA property.

  3. Test the data source.

    1. Navigate to http://localhost:9990 to access the management console page, using admin as username and redhat123 as the password.

    2. Click Configuration to open the configuration page.

    3. Navigate to Subsystems > Datasources & Drivers > Datasources. Click MariaDBXADS and open the drop-down menu to click Test Connection.

      JBoss EAP validates the datasource connection to the lab_db database and the management console shows a success message.

  4. Clean up.

    1. Exit the management CLI:

      [standalone@localhost:9990] exit
    2. Stop the JBoss EAP instance by pressing Ctrl+C in the terminal window that runs it.

Finish

On the workstation machine, use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish datasources-xa

Revision: ad248-7.4-18a9db2