Configuring XA DataSource Connection
Follow these steps to configure an XA DataSource connection for distributed transactions in JBoss Server using the Delinea JDBC Proxy Driver.
Before proceeding, ensure you have completed Step 1: Set Up JDBC Drivers as Modules in Configuring JBoss Web Server.
XA DataSource Configuration Properties
The following properties are used in the XA DataSource configuration. Property names are case-sensitive and must be specified exactly as shown.
| Property | Description |
|---|---|
delinea_secretId
|
(Mandatory) The secret ID that contains database credentials. |
delinea_vendorClass
|
(Mandatory) The wrapped XA DataSource class. Examples:
|
URL
|
(Mandatory) The connection URL to the database. |
delinea_comment
|
(Optional) Add this property only if autoComment is enabled on the secret. |
All delinea_* parameters and the URL parameter must be defined as <xa-datasource-property> elements within the <xa-datasource> block.
Step 2: Configure XA DataSource in standalone.xml
Add an XA DataSource configuration to the standalone.xml file. The standalone.xml file is located in JBOSS_HOME/standalone/configuration.
Example Configuration
The following example defines DelineaXABookDS and DelineaXAStudentDS XA data sources. DelineaXABookDS is the JNDI name for a sample Book database, and DelineaXAStudentDS is the JNDI name for a Student database.
<datasources>
<xa-datasource jndi-name="java:jboss/DelineaXABookDS" pool-name="DelineaXABookDS">
<xa-datasource-property name="delinea_secretId">
11336
</xa-datasource-property>
<xa-datasource-property name="delinea_vendorClass">
com.mysql.cj.jdbc.MysqlXADataSource
</xa-datasource-property>
<xa-datasource-property name="URL">
jdbc:mysql://localhost:3306/xa_jpabook
</xa-datasource-property>
<xa-datasource-class>com.delinea.jdbc.DelineaXADataSource</xa-datasource-class>
<driver>delinea</driver>
</xa-datasource>
<xa-datasource jndi-name="java:jboss/DelineaXAStudentDS" pool-name="DelineaXAStudentDS">
<xa-datasource-property name="delinea_secretId">
11336
</xa-datasource-property>
<xa-datasource-property name="delinea_vendorClass">
com.mysql.cj.jdbc.MysqlXADataSource
</xa-datasource-property>
<xa-datasource-property name="URL">
jdbc:mysql://localhost:3306/xa_jpastudent
</xa-datasource-property>
<xa-datasource-property name="delinea_comment">
frompooledconnection
</xa-datasource-property>
<xa-datasource-class>com.delinea.jdbc.DelineaXADataSource</xa-datasource-class>
<driver>delinea</driver>
</xa-datasource>
<drivers>
<driver name="delinea" module="com.delinea">
<driver-class>com.delinea.jdbc.DelineaDriver</driver-class>
</driver>
<driver name="mysql" module="com.mysql">
<driver-class>com.mysql.cj.jdbc.Driver</driver-class>
</driver>
</drivers>
</datasources>
Important notes:
-
XA DataSources use
<xa-datasource>and<xa-datasource-property>elements instead of<datasource>and<connection-property>. -
The
<xa-datasource-class>must be set tocom.delinea.jdbc.DelineaXADataSource. -
The database URL is specified via the
URLproperty, not in a<connection-url>element. -
Ensure that the
com.delineaandcom.mysqlmodules are correctly configured in JBoss Server (see Step 1 in Configuring JBoss Web Server). -
Verify that the JNDI names (in this example,
java:jboss/DelineaXABookDSandjava:jboss/DelineaXAStudentDS) match your application's requirements.
You can also add data sources and drivers through the JBoss UI: JBoss > Configuration > Subsystems > Datasources & Drivers.
Step 3: Configure the Application Configuration File
Update your application's configuration file (e.g., persistence.xml) to reference the JNDI names defined in Step 2.
For XA DataSources, use <jta-data-source> with transaction-type="JTA":
<persistence-unit name="proxyDriver1" transaction-type="JTA">
<jta-data-source>java:jboss/DelineaXABookDS</jta-data-source>
<class>com.jpa.demo.Book</class>
</persistence-unit>
<persistence-unit name="proxyDriver2" transaction-type="JTA">
<jta-data-source>java:jboss/DelineaXAStudentDS</jta-data-source>
<class>com.jpa.demo.Student</class>
</persistence-unit>
The format of the application configuration file can vary. It can be a .txt, .xml, .properties, or .config file.
After updating the application configuration, restart JBoss Server to apply the changes.
Verification
To verify the integration is working correctly, see JBoss Server Integration Verification.