Creating the data source

You can configure the data source by using the JBoss Management Console or the Management CLI. Here, you use the Management Console.

Procedure

  1. Log in to the JBoss Management Console. By default, http://localhost:9990/console.
  2. In the Configuration tab, navigate to Datasources.
  3. Select the XA DATASOURCES tab.
  4. Click Add, and specify the details for the new data source.
    1. Name:
      • Name: RESDatasource
      • JNDI: java:/jdbc/resdatasource
    2. JDBC Driver:
      • Name: choose the driver
      • XA Data Source Class: org.apache.derby.jdbc.EmbeddedXADataSource
    3. XA Properties (at least the connection URL):
      • Name: CreateDatabase Value: Create
      • Name: DatabaseName Value: c:/resdb
    4. 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>
  5. 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'