Hi,
Unlike JBoss AS 6 there is no “$PROFILE/lib” present in JBoss AS 7 where we can place our JDBC Drivers in order to add/register the JDBC Driver. Also in JBoss AS 7 we don’t need to create a separate DataSource file as “*-ds.xml” file.
In JBoss AS 7 the DataSource configuration is placed wither inside the “Jboss-as-7.0.1.Final/standalone/configuration/standalone.xml” (if you are running a JBoss standalone profile), or the datasource information is placed inside the “boss-as-7.0.1.Final/domain/configuration/domain.xml” file.Here in this demonstration we will see how to install/register a JDBC Driver in JBoss AS7 and then how to create a DataSource from Admin-Console.
You can have a look at the below article for creating MySql Datasource
How to create MySql DataSource And Install MySql JDBC Driver in JBoss AS7
There are two options to install/Register a JDBC Driver to JBoss AS 7.
1). Installing a JDBC driver as a deployment
2). Installing a JDBC driver as a module
Installing a JDBC driver as a deployment
First we need to check which Jdbc Driver are we using? Is it a JDBC 4-compliant driver or a Non-JDBC 4 -compliant driver? Any JDBC 4-compliant driver will automatically be recognized and installed into the system by name and version. A JDBC 4-compliant JAR is identified using the Java service provider mechanism. It contains a text a file named “META-INF/services/java.sql.Driver”, which contains the name of the class(es) of the Drivers which exist in that JAR.
If the driver is already JDBC4-comliant then you can directly deploy it inside the “jboss-as-7.0.1.Final/standalone/deployments” based on the mode which you are using to run your JBoss AS.
Dealing with Non JDBC 4 -compliant Drivers:
If your JDBC Driver is NOT JDBC 4-compliant then we can update the driver using “jar” utility by adding the “META-INF/services/java.sql.Driver” inside it. as following:
Step1). Create a directory somewhere in your file system like “/home/userone/testDriver”
Step2). Place your Non-JDBC 4 compliant driver in this directory “/home/userone/testDriver” suppose your Driver Jar name is “YourJdbcDriver.jar”
Step3). Now create “META-INF/services” directory inside “/home/userone/testDriver”
Step4). Create a file with name “java.sql.Driver” inside “/home/userone/testDriver/META-INF/services” directory and then add the fully qualified name of your JDBC Driver class in this file.
Step5). use the jar utility with -u (means update) option to add the META-INF directory with the above contents in it as following
jar -uf YourJdbcDriver.jar META-INF/services/java.sql.Driver
Now you can take your JDBC Driver and then place it inside the “${JBOSS_AS7}/standalone/deployments”.
The advantage of deploying the JDBC Driver as a deployment in “domain” mode is that the deployments are automatically propagated to all servers to which the deployment applies, so the administrator need not to worry about the the JDBC Driver distribution every time.
Installing a JDBC driver as a module
This is another option to install the JDBC Driver as a module. Which requires that we define a new module for our JDBC Driver inside “${JBOSS_AS7}/modules” directory as following:
Suppose if we want to install the Oracle JDBC Driver (ojdbc6.jar) then we will need to do the following steps:
Step1). Create a directory “oracle/jdbc/main” inside the “jboss-as-7.0.1.Final/modules” directory.
Step2). paste your “ojdbc6.jar” oracle Jdbc Driver inside “jboss-as-7.0.1.Final/modules/oracle/jdbc/main” directory.
Step3). Create a file “module.xml” inside “jboss-as-7.0.1.Final/modules/oracle/jdbc/main” as following:
<?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.0" name="oracle.jdbc"> <resources> <resource-root path="ojdbc6.jar"/> </resources> <dependencies> <module name="javax.api"/> <module name="javax.transaction.api"/> </dependencies> </module>
Step4). Now open your “jboss-as-7.0.1.Final/standalone/configuration/standalone.xml” file or “jboss-as-7.0.1.Final/domain/configuration/domain.xml” file and then add the driver declaration tag refering to your module as following, by default you will see the driver declaration tag already contains the declaration for <driver name=”h2″ module=”com.h2database.h2″>:
<drivers> <driver name="OracleJDBCDriver" module="oracle.jdbc" /> <driver name="h2" module="com.h2database.h2"> <xa-datasource-class> org.h2.jdbcx.JdbcDataSource </xa-datasource-class> </driver> </drivers>
Here we declared the <driver name=”OracleJDBCDriver” module=”oracle.jdbc”/>
Step5). Create a DataSource in your JBoss AS 7 and then in the Driver section you can refer to this Module name “oracle.jdbc”
Creating a DataSource from JBoss AS 7 Admin Console
Step1). After installing the JDBC Driver as mentioned above start your JBoss AS 7 and then login to the admin-console from URL: “http://localhost:9990/console” (as admin/admin credentials)
Step2). From left hand panel of the console click on “Connectors—>DataSources”
Step3). In the right side panel you will see a button “Add” click on this button.
Step4). In Wizard “Step 1/3: Datasource Attributes”
Enter the DataSource Name as “OracleDS”
Enter JNDI Name as “java:/OracleDSJNDI” or “java:jboss/OracleDSJNDI” (NOTE the valid DataSource name should start with either java:/ or with java:jboss/ prefix)
Step5). Now in the next Section “Step 2/3: JDBC Driver” you will see all the installed drivers details. in above case as we already registered oracle driver as a module “OracleJDBCDriver” in previous section so we will be able to see the details as following:
Step6). In next section “” provide the Database url (jdbc:oracle:thin:@10.10.10.10:1521:DB_SID) ,username and password
Step7). you will see following kind of messae in your JBoss AS 7 console output:
10:50:32,330 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) Bound data source [OracleDSJNDI]
For More Details visit:
https://docs.jboss.org/author/display/AS7/Developer+Guide
http://community.jboss.org/wiki/DataSourceConfigurationinAS7#Installing_a_JDBC_driver_as_a_deployment
.
.
Thanks
MiddlewareMagic Team
相关推荐
JDBC驱动包Dm7JdbcDriver17.jar是连接Java应用程序与达梦数据库DM7的关键组件,它简化了数据库操作的过程,使得开发者能够利用Java的强大功能处理DM7中的数据。在Spring Boot项目中,只需将驱动添加至依赖,并正确...
Oracle JDBC Jar包是Java应用程序与Oracle数据库交互的重要组件。它提供了Java编程语言访问Oracle数据库的接口,使得开发者能够在Java环境中执行SQL语句、处理结果集、管理事务等操作。Oracle JDBC驱动主要有四种...
Oracle JDBC驱动11.2.0.4是Oracle公司为Java开发者提供的用于连接Oracle数据库的Java Database Connectivity(JDBC)驱动程序。Oracle JDBC驱动程序允许Java应用程序通过Java代码与Oracle数据库进行交互,执行SQL...
Oracle JDBC驱动主要有四种类型: Thin、 Thick、JDBC-ODBC Bridge和Universal Driver,其中 Thin 驱动是最常用的一种,因为它是一种轻量级的纯Java实现,无需在客户端安装Oracle数据库客户端软件。 ojdbc8-资源....
在IT行业中,JBoss Application Server(JBoss AS)是一款广泛使用的开源Java EE应用服务器,而Oracle则是一款功能强大的关系型数据库管理系统。当我们需要在JBoss 7中与Oracle数据库进行交互时,必须正确配置Oracle...
Oracle Database 12c Release 1 JDBC Driver是一个用于Java应用程序与Oracle数据库进行交互的重要组件。JDBC(Java Database Connectivity)是Java平台的标准API,它允许Java程序员使用SQL语句访问和操作各种类型的...
本文将深入探讨如何通过JDBC(Java Database Connectivity)连接Oracle远程数据库时,解决中文乱码的困扰。 首先,我们需要理解的是,中文乱码通常源于字符集不一致或配置不当。在Java应用中,数据在JVM(Java...
在本篇文章中,我们将详细探讨Oracle JDBC驱动的不同版本,包括ojdbc6.jar、ojdbc7.jar、ojdbc8.jar、ojdbc10.jar以及ojdbc11.jar,以及它们各自的特点和适用场景。 首先,JDBC(Java Database Connectivity)是...
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class> <driver>oracle</driver> <min-pool-size>5 <max-pool-size>20 <prefill>true <user-name>username <password>password ...
spring.datasource.primary.driver-class-name=oracle.jdbc.driver.OracleDriver spring.datasource.primary.url=jdbc:oracle:thin:@localhost:1521:SMARTMES spring.datasource.primary.username=system spring....
* driver-class:修改为 oracle.jdbc.driver.OracleDriver,以指定 Oracle 的 JDBC 驱动程序。 * user-name 和 password:修改为 root 和 123456,以便在 Oracle 数据库中认证用户。 编辑后的 oracle-ds.xml 文件...
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class> <driver>oracle</driver> <user-name>your_username <password>your_password <!-- 可选的其他配置参数,如最大连接数、最小连接数、超时...
Oracle 11.1.0.7.0 JDBC 驱动包是Oracle数据库与Java应用程序之间通信的重要组件,主要用于实现Java程序对Oracle数据库的数据访问。JDBC(Java Database Connectivity)是Java平台上的一个标准API,它允许Java应用...
- `OracleDriver`:实现了JDBC Driver接口,负责注册自身到DriverManager,并处理与Oracle数据库的连接请求。 - `OracleConnection`:Oracle特定的连接实现,扩展了`java.sql.Connection`,提供了Oracle特有的功能。...
driver-class-name: oracle.jdbc.driver.OracleDriver url: jdbc:oracle:thin:@//your-oracle-host:port/service_name username: your-oracle-username password: your-oracle-password ``` 这里,你需要替换 ...
driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@localhost:1521:ORCL" username="your_username" password="your_password" maxActive="100" maxIdle="30" maxWait="10000"/> ....
AS/400 JDBC驱动程序,也称为jt400,是用于与IBM iSeries(以前称为AS/400)系统进行交互的一种关键组件。它允许Java应用程序通过Java Database Connectivity (JDBC) API来连接和操作AS/400上的数据库、中间件和其他...
例如,使用Apache Tomcat的Commons DBCP库,或者内置在应用服务器中的连接池实现,如JBoss的Tomcat JDBC连接池。 最后,确保在项目运行时,JDBC驱动已正确添加到类路径,否则会出现`ClassNotFoundException`。同时...
Oracle.jdbc for Win 是一个专为Windows操作系统设计的Oracle数据库连接驱动包。这个包包含了Java Database Connectivity (JDBC)驱动程序,使得Java应用程序能够与Oracle数据库进行交互。JDBC是Java平台的标准API,...
Class.forName("oracle.jdbc.driver.OracleDriver"); Connection conn = DriverManager.getConnection(url, username, password); System.out.println("Connected to the database!"); // 进行数据库操作... } ...