352 WebSphere Application Server V8.5 Administration and Configuration Guide for the Full Profile
9.1 JDBC resources
The JDBC API provides a programming interface for data access of relational databases from
the Java programming language. WebSphere Application Server V8.5 supports the following
JDBC APIs:
JDBC 4.0
JDBC 3.0
JDBC 2.1 and Optional Package API (2.0)
In the following sections, we explain how to create and configure data source objects for use
by JDBC applications. This is the only method to connect to a database if you intend to use
connection pooling and distributed transactions.
The following database platforms are supported for JDBC:
DB2
Oracle
Sybase
IBM Informix®
SQL Server
Apache Derby (test and development only)
Third-party vendor JDBC data source using SQL99 standards
9.1.1 JDBC providers and data sources
A data source represents a real-world source of data, such as a relational database. When a
data source object is registered with a JNDI naming service, an application can retrieve it
from the naming service and use it to make a connection to the associated database.
Information about the data source and how to locate it, such as its name, the server on which
it resides, its port number, and so on, is stored in the form of
properties on the DataSource
object. Storing this information in this manner makes an application more portable because it
does not need to hard code a driver name, which often includes the name of a particular
vendor. It also makes maintaining the code easier because if, for example, the data source is
moved to a different server, all that needs to be done is to update the relevant property in the
data source. None of the code using that data source needs to be touched.
To increase application performance and reduce workload on the database, connections to it
are typical pooled. In other words, when the application closes the connection, the connection
is returned to a connection pool, rather than being destroyed.
Data source
classes and JDBC drivers are implemented by the data source vendor. By
configuring a JDBC provider, you provide information about the set of classes that are used to
implement the data source and the database driver. Also, you provide the environment
settings for the DataSource object. A driver can be written purely in the Java programming
language or in a mixture of the Java programming language and the Java Native Interface
(JNI) native methods.
In the next sections, we describe how to create and configure data source objects and how to
configure the connection pools used to serve connections from the data source.
Chapter 9. Accessing relational databases from WebSphere 353
9.1.2 WebSphere support for data sources
The programming model for accessing a data source is:
1. An application retrieves a DataSource object from the JNDI naming space.
2. After the DataSource object is obtained, the application code calls the getConnection()
method on the data source to get a Connection object. The connection is obtained from a
pool of connections.
3. After the connection is acquired, the application sends SQL queries or updates to the
database.
In addition to the data source support for Java EE6, Java EE 5, J2EE 1.4, and J2EE 1.3
applications, support is also provided for J2EE 1.2 data sources. The two types of support
differ in how connections are handled. However, from an application point of view, they look
the same.
Data source support
The primary data source support is intended for J2EE 1.3 and J2EE 1.4 and Java EE 5 and
Java EE6 applications. Connection pooling is provided by two components: a JCA
Connection Manager and a relational resource adapter. See Figure 9-1.
Figure 9-1 Resource adapter in J2EE connector architecture
The JCA Connection Manager provides connection pooling, local transactions, and security
support.
Note: The @Resource annotation can be used to declare a reference to a datasource.The
container injects the data source referred to by @Resource into the component either at
runtime or when the component is initialized, depending on whether field/method injection
or class injection is used.
Application Server
Resource
Adapter
DB Connection
Pool
JCA
Connection
Manager
Datasource
Connection
Factory
Delegate
Application
JDBC Driver
DB Server
Connections

Get WebSphere Application Server V8.5 Administration and Configuration Guide for the Full Profile now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.