Creating and configuring <a href="http://www.setgetweb.com/p/i5/portal/WAS60/Configure_JDBC_providerdatsource.html">a JDBC provider and data source</a> using the Java Management Extensions API

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

Why and when to perform this taskIf your application requires access to a JDBC connection pool from a J2EE 1.3 or 1.4 level WebSphere Application Server component, you can create the necessary JDBC provider and data source objects using the Java Management Extensions (JMX) API exclusively. Alternatively, you can use the JMX API in combination with the WSadmin - scripting tool.

Note: Use the JMX API to create only data sources for which the product does not provide a template. For every JDBC provider WebSphere Application Server 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 Vendor-specific data sources minimum required settings. These steps outline the general procedure for using the JMX API to create a JDBC provider and data source, on WebSphere Application Server running on Windows platforms:

  1. Put the appropriate JAR files in your classpath.

    You 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 application server.

    1. Locate the DataSourceConfigHelper MBean using the name.

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

    3. Invoke the reload() call.

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



Sub-topics
Example: Using the Java Management Extensions API to create a JDBC driver and data source for container-managed persistence
Example: Using the Java Management Extensions API to create a JDBC driver and data source for bean-managed persistence, session beans, or servlets
Example: Creating a JDBC provider and data source using Java Management Extensions API and the scripting tool

Related concepts
Connection factory
JDBC providers
Data sources

Related reference
Example: Test a connection using testConnection(ConfigID)
Data sources (Version 4)
Data source collection
CMP connection factories collection