此内容没有您所选择的语言版本。
14.3. Using JDBC Drivers
14.3.1. Install a JDBC Driver as a Core Module 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
Prerequisites
Before performing this task, you need to meet the following prerequisites:
- Download the JDBC driver from your database vendor. JDBC driver download locations are listed here: Section 14.3.2, “JDBC Driver Download Locations”.
- Extract the archive.
Procedure 14.1. Install a JDBC Driver as a Core Module
- Create a file path structure under the
EAP_HOME/modules/
directory. For example, for a MySQL JDBC driver, create a directory structure as follows:EAP_HOME/modules/com/mysql/main/
. - Copy the JDBC driver JAR into the
main/
subdirectory. - In the
main/
subdirectory, create amodule.xml
file. The following is an example of amodule.xml
file:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Start the Server.
- Start the Management CLI.
- Run the following CLI command to add the JDBC driver module as a driver:
/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)
/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)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example 14.1. Example CLI Command
/subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource)
/subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Result
The JDBC driver is now installed and set up as a core module, and is available to be referenced by application datasources.