![Red Hat Application Server Скачать руководство пользователя страница 283](http://html.mh-extra.com/html/red-hat/application-server/application-server_manual_1427406283.webp)
Chapter 40.
Configuring JDBC Resource Adapters
Instead of using the JOnAS database service for configuring DataSources, it is also possible to use
the JOnAS resource service and JDBC connectors compliant with the J2EE Connector Architecture
specification. The resulting functionality is the same, and the benefit is the management of pools
of JDBC PrepareStatements. This chapter describes how the JDBC Resource Adapters should be
configured to connect the application to databases.
40.1. Configuring Resource Adapters
For both container-managed or bean-managed persistence, the JDBC Resource Adapter (JDBC RA)
makes use of relational storage systems through the JDBC interface. JDBC connections are obtained
from a JDBC RA. The JDBC RA implements the J2EE Connector Specification using the
DataSource
interface as defined in the JDBC 2.0 standard extensions. An RA is configured to identify a database
and a means to access it via a JDBC driver. Multiple JDBC RAs can be deployed either via the
jonas.properties
file or included in the autoload directory of the resource service. For complete
information about RAs in JOnAS, refer to Chapter 41
Configuring Resource Adapters
. The following
section explains how JDBC RARs can be defined and configured in the JOnAS server.
To support distributed transactions, the JDBC RA requires the use of at least a JDBC2-XA-compliant
driver. Such drivers implementing the
XADataSource
interface are not always available for all rela-
tional databases. The JDBC RA provides a generic
driver-wrapper
that emulates the XADataSource
interface on a regular JDBC driver. It is important to note that this driver-wrapper does not ensure a
real two-phase commit for distributed database transactions.
The generic JDBC RAs of JOnAS provide implementations of the DriverManager, DataSource,
PooledConnection, and XAConnection interfaces. These can be configured using a JDBC-compliant
driver for some relational database management server products, such as Oracle, PostgreSQL, or
MySQL.
The remainder of this section, which describes how to define and configure JDBC RAs, is
specific to
JOnAS
. However, the way to use these JDBC RAs in the Application Component methods is standard;
that is, via the resource manager connection factory references (refer to the example in Section 8.6
Writing Database Access Operations (Bean-Managed Persistence)
in Chapter 8
Developing Entity
Beans
).
An RAR file must be configured and deployed (for example,
Oracle1.rar
for an Oracle RAR and
MySQL1.rar
for a MySQL RAR, as delivered with the platform).
To define a Resource “Oracle1” in the
jonas.properties
file, add its name “Oracle1” (name of
the RAR file) to the line
jonas.service.resource.services
or just include it in the autoload
directory. For more information about deploying an RAR, refer to Chapter 41
Configuring Resource
Adapters
.
jonas.service.resource.services Oracle1,MySQL1,PostgreSQL1
The
jonas-ra.xml
file that defines a DataSource should contain the following information:
jndiname
JNDI name of the RAR
URL
The JDBC database URL: jdbc:
database_vendor_subprotocol
:...
dsClass
Name of the class implementing the JDBC driver
user
Database user name
Содержание Application Server
Страница 1: ...Red Hat Application Server JOnAS User Guide ...
Страница 8: ......
Страница 22: ...14 Chapter 1 Java Open Application Server JOnAS a J2EE Platform ...
Страница 58: ...50 Chapter 3 JOnAS Configuration ...
Страница 66: ...58 Chapter 5 JOnAS Class Loader Hierarchy ...
Страница 78: ...70 Chapter 6 JOnAS Command Reference ...
Страница 80: ......
Страница 86: ...78 Chapter 7 Developing Session Beans ...
Страница 136: ...128 Chapter 9 Developing Message Driven Beans ...
Страница 142: ...134 Chapter 10 Defining the Deployment Descriptor ...
Страница 148: ...140 Chapter 11 Transactional Behavior of EJB Applications ...
Страница 158: ...150 Chapter 14 EJB Packaging ...
Страница 162: ...154 Chapter 15 Application Deployment and Installation Guide ...
Страница 164: ......
Страница 176: ...168 Chapter 18 WAR Packaging ...
Страница 178: ......
Страница 184: ...176 Chapter 20 Defining the Client Deployment Descriptor ...
Страница 186: ...178 Chapter 21 Client Packaging ...
Страница 188: ......
Страница 192: ...184 Chapter 23 EAR Packaging ...
Страница 194: ......
Страница 200: ...192 Chapter 24 JOnAS Services ...
Страница 204: ...196 Chapter 25 JOnAS and the Connector Architecture ...
Страница 222: ...214 Chapter 27 Ant EJB Tasks Using EJB JAR ...
Страница 234: ...226 Chapter 29 Web Services with JOnAS ...
Страница 236: ......
Страница 260: ...252 Chapter 34 How to use Axis in JOnAS ...
Страница 270: ...262 Chapter 36 Web Service Interoperability between JOnAS and BEA WebLogic ...
Страница 296: ......