Installing a JDBC driver as the core module

You must install a driver before creating the data source.

Before you begin

Download the JDBC driver from your database vendor.

Procedure

  1. Create a file path structure under the <JBOSS_HOME>/modules directory.
    For example, for a Derby driver, create the following directory structure: <JBOSS_HOME>/modules/com/ibm/derby/main.
  2. Copy the JDBC driver JAR file into the main subdirectory.
  3. In the main subdirectory, create a module.xml file.
    Example for Derby:
    <module xmlns="urn:jboss:module:1.1" name="com.ibm.derby"> 
        <properties> 
            <property name="jboss.api" value="unsupported"/> 
        </properties> 
        <resources> 
            <resource-root path="derby.jar"/> 
            <!-- Insert resources here --> 
        </resources> 
        <dependencies> 
            <module name="javax.api"/> 
            <module name="javax.transaction.api"/> 
            <module name="javax.servlet.api" optional="true"/> 
        </dependencies> 
    </module>

    The module XSD is defined in the <JBOSS_HOME>/docs/schema/module-1_2.xsd file.

  4. Start the server:
    1. Go to <JBOSS_HOME>/bin
    2. In stand-alone mode, run ./standalone[.sh|.bat] -c standalone-full.xml
    3. In another command prompt, start the Management CLI: <JBOSS_HOME>/bin/jboss-cli[.sh|.bat]
    4. Enter connect.
  5. To add the JDBC driver module as a driver, run the following CLI command:
    /subsystem=datasources/jdbc-driver=DRIVER_NAME:add(driver-name=DRIVER_NAME,driver-module-name=MODULE_NAME,driver-xa-datasource-class-name=XA_DATASOURCE_CLASS_NAME)
    Example: /subsystem=datasources/jdbc-driver=derby:add(driver-name=derby,driver-module-name=com.ibm.derby,driver-xa-datasource-class-name=org.apache.derby.jdbc.EmbeddedXADataSource)

Results

The JDBC driver is now installed and set up as the core module. It can be referenced by a data source.