Chapter 4.
Configuring JDBC DataSources
This chapter shows the bean or application deployer how to configure the DataSources to connect the
application to databases.
4.1. Configuring DataSources
For both container-managed and bean-managed persistence, JOnAS makes use of relational
storage systems through the JDBC interface. JDBC connections are obtained from an object, the
DataSource
, provided at the application server level. The DataSource interface is defined in
the JDBC 2.0 standard extensions (see http://java.sun.com/products/jdbc/). A DataSource object
identifies a database and a means to access it via a JDBC driver. An application server may request
access to several databases and thus provide the corresponding DataSource objects. Available
DataSource objects can be added on the platform; they must be defined in the
jonas.properties
file. This section explains how DataSource objects can be defined and configured in the JOnAS
server.
To support distributed transactions, JOnAS requires the use of a JDBC2-XA-compliant driver. Such
drivers that implement the
XADataSource
interface are not always available for all relational
databases. JOnAS provides a generic
driver-wrapper
that emulates the XADataSource interface on a
regular JDBC driver.
Important
It is important to note that this driver-wrapper does not ensure a real two-phase commit for distributed
database transactions.
JOnAS’s generic
driver-wrapper
provides an implementation of the DataSource interface that al-
lows DataSource objects to be defined using a JDBC1-compliant driver for some relational databases,
such as Oracle and PostgreSQL.
Neither the EJB specification nor the J2EE specification describe how to define DataSource objects so
that they are available to a J2EE platform. Therefore, this document, which describes how to define
and configure DataSource objects, is
specific to JOnAS
. However, the way to use these DataSource
objects in the Application Component methods is standard; that is, by using the resource manager con-
nection factory references (refer to the example in Section 8.6
Writing Database Access Operations
(Bean-Managed Persistence)
).
A DataSource object should be defined in a file called
DataSourcename
.properties
(for example,
Oracle1.properties
for an Oracle DataSource), as delivered with the platform.
In the
jonas.properties
file, to define a DataSource “Oracle1”, add the name
Oracle1
(the same
name as in the properties file) to the line
jonas.service.dbm.datasources
, as follows:
jonas.service.dbm.datasources Oracle1,PostgreSQL
The property file defining a DataSource should contain the following information:
datasource.name
JNDI name of the DataSource
Summary of Contents for Application Server
Page 1: ...Red Hat Application Server JOnAS User Guide ...
Page 8: ......
Page 22: ...14 Chapter 1 Java Open Application Server JOnAS a J2EE Platform ...
Page 58: ...50 Chapter 3 JOnAS Configuration ...
Page 66: ...58 Chapter 5 JOnAS Class Loader Hierarchy ...
Page 78: ...70 Chapter 6 JOnAS Command Reference ...
Page 80: ......
Page 86: ...78 Chapter 7 Developing Session Beans ...
Page 136: ...128 Chapter 9 Developing Message Driven Beans ...
Page 142: ...134 Chapter 10 Defining the Deployment Descriptor ...
Page 148: ...140 Chapter 11 Transactional Behavior of EJB Applications ...
Page 158: ...150 Chapter 14 EJB Packaging ...
Page 162: ...154 Chapter 15 Application Deployment and Installation Guide ...
Page 164: ......
Page 176: ...168 Chapter 18 WAR Packaging ...
Page 178: ......
Page 184: ...176 Chapter 20 Defining the Client Deployment Descriptor ...
Page 186: ...178 Chapter 21 Client Packaging ...
Page 188: ......
Page 192: ...184 Chapter 23 EAR Packaging ...
Page 194: ......
Page 200: ...192 Chapter 24 JOnAS Services ...
Page 204: ...196 Chapter 25 JOnAS and the Connector Architecture ...
Page 222: ...214 Chapter 27 Ant EJB Tasks Using EJB JAR ...
Page 234: ...226 Chapter 29 Web Services with JOnAS ...
Page 236: ......
Page 260: ...252 Chapter 34 How to use Axis in JOnAS ...
Page 270: ...262 Chapter 36 Web Service Interoperability between JOnAS and BEA WebLogic ...
Page 296: ......