+

Search Tips   |   Advanced Search

Set a JDBC provider and data source


For access to relational databases, applications use the JDBC drivers and data sources that you configure for the appserver.

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 appserver obtains and manages the physical connections for transactions between applications and the database.

If accessing a DB2 database, Data Studio pureQuery is an alternative to JDBC.

See on pureQuery, see the topic "Task overview: Data Studio pureQuery" in the related links section. Determine the version of data source that we need according to the API spec of the applications.

 

  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.

    From the admin console, see the topic, Creating a JDBC provider using the admin console.

    OR

    Use the wsadmin scripting client, see the topic, Set a JDBC provider using the scripting.

    OR

    Use the Java Management Extensions (JMX) API, see the topic, Creating a JDBC provider and data source using the Java Management Extensions API.

  3. Create a data source.

    From the admin console, see the topic, Creating a data source using the admin console.

    OR

    Use the wsadmin scripting client, see the topic, Set new data sources using scripting. For V4 data sources, see the topic, Set new WAS40 data sources using scripting.

    OR

    Use the JMX API, see the topic, Creating a JDBC provider and data source using the Java Management 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 admin console surfaces the required properties and prompts you for them as you create a data source. However, if we script your data access configurations, consult the article Data source minimum required settings, by vendor, for the required properties and settings options.

  4. Set custom properties. Like the required properties, custom properties for specific vendor JDBC drivers must be set on the appserver 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 appserver, refer to the topic, Developing a custom DataStoreHelper class.

    We can also learn about optional data source properties in the Application Programming Guide and Reference for Java for your version of DB2 for z/OS if we use the DB2 Universal JDBC Driver provider.

  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, we might experience data source failures that the appserver 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 we 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 admin console.

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


Data source minimum required settings, by vendor
Set a JDBC provider
Set a JDBC provider for a clustered environment
Set a data source
Create and configuring a JDBC provider and data source using the Java Management Extensions API
Use the DB2 Universal JDBC Driver to access DB2 for z/OS
Extend DB2 data source definitions at the application level
Enable trusted context for DB2 databases
Set the appserver and DB2 to authenticate with Kerberos
Set Oracle Real Application Cluster (RAC) with the appserver
Set client reroute for applications that use DB2 databases
Develop a custom DataStoreHelper class
Verifying a connection
Test connection service
Testing a connection with the admin console
Testing a connection using wsadmin

 

Related concepts


JDBC providers
Data sources
The benefits of using resource references
Data source lookups for enterprise beans and Web modules

 

Related tasks


Set a JDBC provider using scripting
Set new data sources using scripting
Set new WAS40 data sources using scripting
Task overview: Data Studio pureQuery

 

Related


Data source collection
Data source (WAS V4) collection
JDBC provider collection