WAS v8.5 > Administer applications and their environment > Welcome to administering EJB applications > Administer applications that use the Java Persistence API > Configure JPA to work in the environmentConfigure a JDBC provider and data source
For access to relational databases, applications use the JDBC drivers and data sources that you configure for the application server.
Each vendor database requires different JDBC driver implementation classes for JDBC connectivity. A JDBC provider encapsulates those vendor-specific driver files. Through the data source that you associate with the JDBC provider, an application server obtains and manages the physical connections for transactions between applications and the database.
If we are accessing a DB2 database, IBM Optim pureQuery Runtime is an alternative to JDBC. For more information on pureQuery, see the topic, Tasks: IBM Optim pureQuery Runtime, in the related links section.
Before starting this task, determine the version of data source that you need according to the API specification of the applications.
- Data sources (WebSphere Application Server Version 4) are for use with the EJB 1.0 specification and the Java Servlet 2.2 specification.
- Data sources of the latest standard version are for use with applications that implement the more advanced releases of these specifications.
- Verify that all of the necessary JDBC driver files are installed on the application server. Consult the article, Data source minimum required settings, by vendor for that information. If we opt to configure a user-defined JDBC provider, check the database documentation for information about the driver files.
- Create a JDBC provider.
When creating a JDBC provider from the dmgr console, see the topic, Configuring a JDBC provider using the dmgr console; or
Using the wsadmin scripting client, see the topic, Configuring a JDBC provider using the scripting; or
Using the Java Management Extensions (JMX) API, see the topic, Creating a JDBC provider and data source using the JavaManagement Extensions API.
- Create a data source.
From the dmgr console, see the topic, Creating a data source using the dmgr console; or
Using the wsadmin scripting client, see the topic, Configuring new data sources using scripting. For V4 data sources, see the topic, Configuring new WAS40 data sources using scripting; or
Using the JMX API, see the topic, Creating a JDBC provider and data source using the JavaManagement Extensions API.
Required properties: Different database vendors require different properties for implementations of their JDBC drivers. Set these properties on the WAS data source. Because Application Server contains templates for many vendor JDBC implementations, the dmgr console surfaces the required properties and prompts you for them as you create a data source. However, if you script your data access configurations, you must consult the article Data source minimum required settings, by vendor, for the required properties and settings options.
- Optional: Configure custom properties.
Like the required properties, custom properties for specific vendor JDBC drivers must be set on the application server data source. Consult the database documentation for information about available custom properties. To configure a custom class to facilitate the handling of database properties that are not recognized natively by the Application Server, refer to the topic, Developing a custom DataStoreHelper class.
There are also optional data source properties, such as the DB2 sslConnection custom property, that you might want to configure. Refer to the Application Programming Guide and Reference for Java for the version of DB2 for z/OS if we use the DB2 Universal JDBC Driver provider for more information about these custom properties.
- Bind resource references to the data source. See the article, Data source lookups for enterprise beans and web modules.
- Test the connection (for non-container-managed persistence usage). See the topic, Test connection service.
Results
If we use the DB2 JDBC Universal Driver, you might experience data source failures the application server JVM log does not document. Check the DB2 database log or the WAS JDBC trace.log (if JDBC trace was active). You might find that a bad authentication credential is the cause of failure. Currently the DB2 JDBC Universal Driver does not identify or surface the errors produced by non-valid authentication credentials in a proper or consistent way.Even if you receive information about a bad credential, check the database and JDBC trace logs. These logs provide more reliable, detailed error data on authentication failures.
Best practice: The JDBC trace.log exists only if the JDBC trace service is active during server start up. Activate the service in the dmgr console. For more information, see the topic, Enabling trace at server startup. Specify WAS.database as the trace group and select com.ibm.ws.db2.logwriter as the trace string.
Subtopics
- Data source minimum required settings, by vendor
Set the appropriate properties on every data source that you configure.- Configure a JDBC provider
To create connections between an application and a relational database, the application server uses the driver implementation classes that are encapsulated by the JDBC provider.- Configure a data source
Application components use a data source to access connection instances to a relational database.- Configure a JDBC provider and data source using the JMX API
If the application requires access to a relational database using the JDBC API, we can create the necessary JDBC provider and data source objects using the JMX API exclusively. Alternatively, we can use the JMX API in combination with the wsadmin scripting tool.- Use the DB2 Universal JDBC Driver to access DB2 for z/OS
The z/OS operating system requires that you configure the DB2 Universal JDBC Driver and the database to ensure interoperability. Within WAS, configure a JDBC provider object and a data source object to implement the driver capabilities for the applications.- Extend DB2 data source definitions at the application level
Extend data source definitions, which consist of non-core or custom properties, for DB2 data sources to add a greater level of application flexibility when we are using the DB2 Universal JDBC driver or DB2 Using IBM JCC driver. This capability is sometimes referred to as heterogeneous pooling. Configure a DB2 data source in the application server with a core set of data source properties, and defer to individual applications to define any custom or non-core properties, like currentSchema or clientApplicationInformation, to be application specific. We can also use these extended definitions to override any non-core or custom properties that are already defined for the data source. In addition, this feature can reduce the number of physical connections the application server uses by employing one connection pool between resources that connect to the same data source.- Enable trusted context for DB2 databases
Enable trusted context in the applications to improve how the application server interacts with DB2 database servers. Use trusted connections to preserve the identity records of clients that are connecting to a DB2 database through the applications; trusted connections can provide a more secure environment by granting access based on the identity of those users.- Configure the application server and DB2 to authenticate with Kerberos
The Kerberos authentication mechanism may be used when both WAS and the DB2 server are configured for Kerberos authentication. Kerberos authentication can provide single sign on (SSO) end-to-end interoperable solutions and preserves the original requester identity.- Create a data source that uses the Oracle JDBC Driver for OCI
We can use the Oracle JDBC for OCI with v8.5 of the Application Server.- Configure Oracle Real Application Cluster (RAC) with the application server
Oracle Real Application Cluster (RAC) is a "share-everything" database architecture in which two or more Oracle RAC nodes are clustered together and share the same storage. The RAC nodes are connected together with a high-speed interconnect that enables fast communication between the Oracle nodes. The nodes can exchange various categories of data block ownership information during startup, lock information, exchange transaction information and data, and so on.- Configure client reroute for applications that use DB2 databases
The client reroute feature enables you to configure your client applications for a DB2 universal database to recover from a communication loss, and the applications can continue to work with minimal interruption. Rerouting is central to the support of continuous operations, but rerouting is only possible when there is an alternate location identified to the client connection.- Develop a custom DataStoreHelper class
Apply the WebSphere extension, GenericDataStoreHelper class, to create our own data store helper for data sources the application server does not support. With this helper class, your JDBC configuration can use database-specific functions during transactions.- Verifying a data source connection
Many connection problems can be easily fixed by verifying configuration parameters. There are steps that you must complete to enable a successful connection.- Test connection service
WAS provides a test connection service for validating data source configurations. The testConnection operation instantiates the data source configuration, gets a connection, and then immediately closes the connection.- Testing a connection with the dmgr console
After we have defined and saved a data source, we can click the Test Connection button to ensure the parameters in the data source definition are correct.- Testing a connection using wsadmin
The AdminControl object of the wsadmin scripting tool has a testConnection operation that tests the configuration properties of a data source object.- Data source minimum required settings, by vendor
Set the appropriate properties on every data source that you configure.- Configure a JDBC provider
To create connections between an application and a relational database, the application server uses the driver implementation classes that are encapsulated by the JDBC provider.- Configure a data source
Application components use a data source to access connection instances to a relational database.- ResourceManagement command group for AdminTask
We can use the Jython or Jacl scripting languages to configure resource providers with wsadmin. The commands and parameters in the ResourceManagement group can be used to define and display properties for resource providers.- Configure a JDBC provider and data source using the JMX API
If the application requires access to a relational database using the JDBC API, we can create the necessary JDBC provider and data source objects using the Java Management Extensions (JMX) API exclusively. Alternatively, we can use the JMX API in combination with the wsadmin scripting tool.- Access an existing Java EE data source resource
The same DataSource MBean and JDBCProvider MBean programming model that we use to access a WAS managed data source (defined in scripting or the Integrated Solutions Console) can be used to access a Java™ Platform Enterprise Edition (Java EE) data source resource defined in the application with the DataSourceDefinition annotation or with the <data-source> element of the deployment descriptor. This feature maintains compatibility with existing scripts, simplifying the management of your resources.- Use the DB2 Universal JDBC Driver to access DB2 for z/OS
The z/OS operating system requires that you configure the DB2 Universal JDBC Driver and the database to ensure interoperability. Within WAS, configure a JDBC provider object and a data source object to implement the driver capabilities for the applications.- Create a data source that uses the Oracle JDBC Driver for OCI
We can use the Oracle JDBC for OCI with v8.5 of the Application Server.- Configure Oracle Real Application Cluster (RAC) with the application server
Oracle Real Application Cluster (RAC) is a "share-everything" database architecture in which two or more Oracle RAC nodes are clustered together and share the same storage. The RAC nodes are connected together with a high-speed interconnect that enables fast communication between the Oracle nodes. The nodes can exchange various categories of data block ownership information during startup, lock information, exchange transaction information and data, and so on.- Configure client reroute for applications that use DB2 databases
The client reroute feature enables you to configure your client applications for a DB2 universal database to recover from a communication loss, and the applications can continue to work with minimal interruption. Rerouting is central to the support of continuous operations, but rerouting is only possible when there is an alternate location identified to the client connection.- Configure client affinities for applications that use DB2 databases
The client affinities feature is an alternative to automatic client reroute when enabling your data source to use other servers when a connection fails. In this client-only method, the client determines the order that alternate servers run during failover. For more information about client affinities, see the topic, Client affinities for DB2 Database for Linux, UNIX, and Windows, in the DB2 information center.- Verifying a data source connection
Many connection problems can be easily fixed by verifying configuration parameters. There are steps that you must complete to enable a successful connection.- Test connection service
WAS provides a test connection service for validating data source configurations. The testConnection operation instantiates the data source configuration, gets a connection, and then immediately closes the connection.- Testing a connection with the dmgr console
After we have defined and saved a data source, we can click the Test Connection button to ensure the parameters in the data source definition are correct.- Testing a connection using wsadmin
The AdminControl object of the wsadmin scripting tool has a testConnection operation that tests the configuration properties of a data source object.- Configure data source JDBC providers to use pureQuery in a Java SE environment
Use this task to configure the application data source JDBC provider to use pureQuery to access DB2 in a Java Standard Edition (Java SE) environment.
Related concepts:
JDBC providers
Data sources
Resource reference benefits
Data source lookups for enterprise beans and web modules
Related
Configure a JDBC provider using wsadmin
Configure new data sources using wsadmin
Configure new WAS40 data sources using wsadmin.sh
Tasks: IBM Optim pureQuery Runtime
Reference:
Data source page
Data source (WAS V4) page
JDBC provider page