Configuring XA DataSource Connection
Step 1: Run the SetupUtlity.jar
Run the SetupUtility.jar
For detailed instructions, see Setup.
Step 2: Configuring Context File
Navigate to the Apache Tomcat configuration directory and edit the context configuration file:
C:\Program Files\Apache Software Foundation\Tomcat 10.1\conf\context.xml
The Tomcat server configuration file using native XA JDBC drivers appears as follows:
<Resource name="jdbc/book"
auth="Container"
type="javax.sql.XADataSource"
xaDataSourceClassName="com.mysql.cj.jdbc.MysqlXADataSource"
serverName="localhost"
portNumber="3306"
databaseName="databaseName"
user="dbuser"
password="dbpassword"
maxIdle="10"
maxTotal="25"
/>
<Resource name="jdbc/student"
auth="Container"
type="javax.sql.XADataSource"
xaDataSourceClassName="oracle.jdbc.xa.client.OracleXADataSource"
URL="jdbc:oracle:thin:@//localhost:1521/xepdb1"
user="dbuser"
password="dbpassword"
maxIdle="10"
maxTotal="25"
/>
Update the existing XA DataSource configuration to use the Delinea JDBC Driver:
<Resource name="jdbc/book"
auth="Container"
type="javax.sql.XADataSource"
factory="com.delinea.jdbc.DelineaXADataSourceFactory"
maxIdle="10"
maxTotal="25"
connectionProperties="
URL=jdbc:mysql://localhost:3306/DBname;
delinea_secretId=62;
delinea_vendorClass=com.mysql.cj.jdbc.MysqlXADataSource"
/>
<Resource name="jdbc/student"
auth="Container"
type="javax.sql.XADataSource"
factory="com.delinea.jdbc.DelineaXADataSourceFactory"
maxIdle="10"
maxTotal="25"
connectionProperties="
URL=jdbc:oracle:thin:@//localhost:1521/xepdb1;
delinea_vendorClass=oracle.jdbc.xa.client.OracleXADataSource";
delinea_secretId=61;
delinea_comment=Need DB credentials;
/>
Configuration Properties
The following table lists the Delinea driver configuration properties. The 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:
|
delinea_comment
|
(Optional) Add this property only if autoComment is enabled on the secret. |
| URL (Mandatory) | The connection URL. URL to the database. |
All delinea_* parameters must be defined in the
connectionProperties attribute.
When using XA DataSources, ensure the
factory="com.delinea.jdbc.DelineaXADataSourceFactory"
attribute appears in the Resource tag.
Step 3: Configuring Application Configuration File
Navigate to the directory where the application is deployed:
C:\Program Files\Apache Software Foundation\Tomcat 10.1\conf\webapps
Edit the application configuration file. Depending on the application, the configuration
file format may vary (for example, .txt, .xml,
.properties, or .config).
The following example shows a Java JPA application configured with multiple XA data sources:
<persistence-unit name="PersistenceUnit1" transaction-type="JTA">
<jta-data-source>java:comp/env/jdbc/book</jta-data-source>
<class>com.jpa.entity.Book</class>
</persistence-unit>
<persistence-unit name="PersistenceUnit2" transaction-type="JTA">
<jta-data-source>java:comp/env/jdbc/student</jta-data-source>
<class>com.jpa.entity.Student</class>
</persistence-unit>
In this example, the application is configured with two XA data sources:
java:comp/env/jdbc/bookjava:comp/env/jdbc/student
- DataSource: Specifies the JNDI name of the database resource.
- Always add the prefix
java:comp/env/before the DataSource name. - Key names may vary depending on the application implementation.