You can configure the data source by using the JBoss Management
Console or the Management CLI. Here, you use the Management Console.
Procedure
- Log in to the JBoss Management Console. By default, http://localhost:9990/console.
- In the Configuration tab, navigate
to Datasources.
- Select the XA DATASOURCES tab.
- Click Add, and specify the details
for the new data source.
- Name:
- Name: RESDatasource
- JNDI: java:/jdbc/resdatasource
- JDBC Driver:
- Name: choose the driver
- XA Data Source Class: org.apache.derby.jdbc.EmbeddedXADataSource
- XA Properties (at least the connection URL):
- Name: CreateDatabase Value:
Create
- Name: DatabaseName Value:
c:/resdb
- Connection Settings:
- Username: the user name for a new connection.
Example: RES
- Password: the password for the new connection.
Example: RES
- Security domain: the security domain that
defines the javax.security.auth.Subject parameter
used to distinguish connections in the pool. Example: <Empty>
- Select the newly created data source and then click the Enable button.
Example
You can also create the data source by using a script. Here
is an example script for Derby:
./jboss-cli.sh --connect 'xa-data-source add --name=RESDatasource --jndi-name=java:/jdbc/resdatasource --user-name=RES --password=RES --driver-name=derby --xa-datasource-class=org.apache.derby.jdbc.EmbeddedXADataSource'
./jboss-cli.sh --connect '/subsystem=datasources/xa-data-source=RESDatasource/xa-datasource-properties=CreateDatabase:add(value=Create)'
./jboss-cli.sh --connect '/subsystem=datasources/xa-data-source=RESDatasource/xa-datasource-properties=DatabaseName:add(value=/tmp/data/derby/resdb)'
./jboss-cli.sh --connect 'xa-data-source enable --name=RESDatasource'