+

Search Tips   |   Advanced Search

 

Create and configuring a JDBC provider and data source using the Java Management Extensions API

 

If your application requires access to a JDBC connection pool from a J2EE 1.3 or 1.4 level WAS component, you can create the necessary JDBC provider and data source objects using the Java Management Extensions (JMX) API exclusively.

 

Overview

Alternatively, you can use the JMX API in combination with the WSadmin - scripting tool.

Use the JMX API to create only data sources for which the product does not provide a template. For every JDBC provider WAS supports, the product provides a corresponding data source template. You can create supported providers and associated data sources through the administrative console, or by using the WSadmin - scripting tool. For a complete list of supported JDBC providers (and therefore a complete list of data sources that must be created using a template), refer to the topic Data source minimum required settings, by vendor. These steps outline the general procedure for using the JMX API to create a JDBC provider and data source, on WAS running on Windows platforms.

 

Procedure

  1. Put the appropriate JAR files in your classpath.

    We need two JAR files in your classpath -- wsexception.jar and wasjmx.jar. The following command is an example for setting your classpath:

    set classpath=%classpath%;D:\WebSphere\AppServer\lib\wsexception.jar;D:\WebSphere\AppServer\lib\wasjmx.jar
    
    

  2. Look up the host and get an administration client handle.

  3. Get a configuration service handle.

  4. Update the resource.xml file using the configuration service as desired.

    1. Add a JDBC provider.

    2. Add the data source.

    3. Add the connection factory. This step is necessary only for data sources that must support container-managed persistence.

  5. Reload the resource.xml file to bind the newly created data source into the JNDI namespace. Perform this step if you want to use the newly created data source right away without restarting the appserver.

    1. Locate the DataSourceConfigHelper MBean using the name.

    2. Put together the signature and parameters for the call.

    3. Invoke the reload() call.

     

  6. If you modify the class path or native library path of an existing JDBC provider, restart every appserver within the scope of that JDBC provider for the new configuration to work. Otherwise, you receive a data source failure message.



Example: Using the Java Management Extensions API to create a JDBC driver and data source for a CMP bean

Example: Using the Java Management Extensions API to create a JDBC driver and data source for BMP beans, session beans, or servlets

Example: Creating a JDBC provider and data source using Java Management Extensions API and the scripting tool

 

Related concepts


JDBC providers
Data sources

 

Related Reference


Example: Testing a connection using testConnection(ConfigID)
Data sources (WAS V4)
Data source collection
CMP connection factories collection
JDBC provider collection