+

Search Tips   |   Advanced Search

Configure a JDBC provider and data source

For access to relational databases, applications use the JDBC drivers and data sources configured 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, Task overview: IBM Optim pureQuery Runtime, in the related links section.

Before starting this task, determine the version of data source that we need according to the API specification of the applications.

(zos) Important: If we connect to DB2 for z/OS through the JDBC Universal JDBC Driver, follow the steps that are outlined in the topic, Using the DB2 Universal JDBC Driver to access DB2 for z/OS. This article gives detailed instruction on installing the JDBC driver and related files, plus activating required JDBC properties.

  1. Verify that all of the necessary JDBC driver files are installed on the node manager. 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.

  2. Create a JDBC provider.

    When creating a JDBC provider from the administrative console, see the topic, Configuring a JDBC provider using the administrative console; or

    Use the wsadmin scripting client, see the topic, Configuring a JDBC provider using the scripting; or

    Use the JMX API, see the topic, Creating a JDBC provider and data source using the JavaManagement Extensions API.

  3. Create a data source.

    From the administrative console, see the topic, Creating a data source using the administrative console; or

    Use the wsadmin scripting client, see the topic, Configuring new data sources . For V4 data sources, see the topic, Configuring new WAS40 data sources ; or

    Use 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 administrative console surfaces the required properties and prompts you for them as we create a data source. However, if you script the data access configurations, you must consult the article Data source minimum required settings, by vendor, for the required properties and settings options.

  4. 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 your version of DB2 for z/OS if you use the DB2 Universal JDBC Driver provider for more information about these custom properties.

  5. Bind resource references to the data source. See the article, Data source lookups for enterprise beans and web modules.

  6. 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 that the application server JVM log does not document. Check the DB2 database log or the WAS JDBC trace log (if JDBC trace was active). We 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 that are 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 administrative console. For more information, see the topic, Enable trace at server startup. Specify WAS.database as the trace group and select com.ibm.ws.db2.logwriter as the trace string.bprac


Subtopics


Related concepts

  • JDBC providers
  • Data sources
  • Resource reference benefits
  • Data source lookups for enterprise beans and web modules


    Related tasks

  • Configure a JDBC provider using wsadmin
  • Configure new data sources using wsadmin
  • Configure new WAS40 data sources
  • Extend DB2 data source definitions at the application level
  • Enable trusted context for DB2 databases
  • Configure the application server and DB2 to authenticate with Kerberos
  • Develop a custom DataStoreHelper class
  • Task overview: IBM Optim pureQuery Runtime

  • Data source collection
  • Data source (WebSphere Application Server V4) collection
  • JDBC provider collection