JDBCProviderManagement command group for AdminTask object
We can use the Jython or Jacl scripting languages in interactive mode to configure data access and data sources . The commands and parameters in the JDBCProviderManagement group can be used to create or list data sources and Java database connectivity (JDBC) providers.
The JDBCProviderManagement (AdminTask) includes the following commands:
- createDatasource
- createJDBCProvider
- deleteDatasource
- deleteJDBCProvider
- listDatasources
- listJDBCProviders
createDatasource
The createDatasource command creates a new data source to access the back end data store. Application components use the data source to access connection instances to the database.
Target object JDBC Provider Object ID - The configuration object of the JDBC provider to which the new data source will belong.
Required parameters
- - name
- The name of the data source. (String, required)
- -jndiName
- The Java Naming and Directory Interface (JNDI) name. (String, required)
- -dataStoreHelperClassName
- The name of the DataStoreHelper implementation class that extends the capabilities of the selected JDBC driver implementation class to perform data-specific functions. WebSphere Application Server provides a set of DataStoreHelper implementation classes for each of the JDBC provider drivers it supports. (String, required)
- configureResourceProperties
- This command step configures the resource properties that are required by the data source. (Required) We can specify the following parameters for this step:
- name
- The name of the resource property. (String, required)
- type
- The type of the resource property. (String, required)
- value
- The value of the resource property. (String, required)
Optional parameters
- -description
- The description of the data source. (String, optional)
- -category
- The category that we can use to classify a group of data sources. (String, optional)
- -componentManagedAuthenticationAlias
- The alias used for database authentication at run time. This alias is only used when the application resource reference is using res-auth=Application. (String, optional)
- -containerManagedPersistence
- Specifies if the data source is used for container managed persistence for enterprise beans. The default value is true. (Boolean, optional)
Examples
Batch mode example:
- Jacl:
$AdminTask createDatasource "DB2 Universal JDBC Driver Provider (XA)(cells/myCell|resources.xml# JDBCProvider_1180538152781)" {-name "DB2 Universal JDBC Driver XA DataSource" -jndiName s1 -dataStoreHelperClassName com.ibm.websphere.rsadapter.DB2UniversalDataStoreHelper -componentManagedAuthenticationAlias myCellManager01/a1 -xaRecoveryAuthAlias myCellManager01/a1 -configureResourceProperties {{databaseName java.lang.String db1} {driverType java.lang.Integer 4} {serverName java.lang.String dbserver1} {portNumber java.lang.Integer 50000}}}
- Jython string...
AdminTask.createDatasource('DB2 Universal JDBC Driver Provider(XA) (cells/myCell|resources.xml #JDBCProvider_1180501752515)', '[-name "DB2 Universal JDBC Driver XA DataSource 2" -jndiName ds2 -dataStoreHelperClassName com.ibm.websphere.rsadapter.DB2UniversalDataStoreHelper -componentManagedAuthenticationAlias myCellManager01/a1 -xaRecoveryAuthAlias myCellManager01/a1 -configureResourceProperties [[databaseName java.lang.String db1] [driverType java.lang.Integer 4] [serverName java.lang.String dbserver1] [portNumber java.lang.Integer 50000]]]')
- Jython list:
AdminTask.createDatasource('DB2 Universal JDBC Driver Provider(XA) (cells/myCell|resources.xml# JDBCProvider_1180501752515)', ['-name', ' DB2 Universal JDBC Driver XA DataSource 2', '-jndiName', 'ds2', '-dataStoreHelperClassName', 'com.ibm.websphere.rsadapter.DB2UniversalDataStoreHelper', '-componentManagedAuthenticationAlias', 'myCellManager01/a1', '-xaRecoveryAuthAlias', 'myCellManager01/a1', '-configureResourceProperties', '[[databaseName java.lang.String db1] [driverType java.lang.Integer 4] [serverName java.lang.String dbserver1] [portNumber java.lang.Integer 50000]]'])
Interactive mode:
- Jacl:
$AdminTask createDatasource {-interactive}
- Jython:
AdminTask.createDatasource('-interactive')
Avoid trouble: Be aware of the following issues with the createDatasource command:
- When creating a data source that supports container-managed persistence, the createDatasource command creates two objects in the configuration of the target scope: the intended data source and a CMP connector factory used expressly by the container. We must apply the remove command separately to the intended data source and the CMP connector factory objects in order to delete the data source from the configuration.
The following script illustrates how to use Jacl to remove the CMPConnectorFactory object from the configuration when we delete a data source that supports container-managed persistence:
# The following script removes a data source from the configuration, # including the associated CMP connector factory # # Set this variable to the ID string of the data source to remove set ds_to_remove "configID_of_my_data_source_to_remove" puts "Data source to remove='$ds_to_remove'" # Find and remove the CMPConectorFactory associated with the datasource to remove foreach cmp_cf [$AdminConfig list CMPConnectorFactory] { set cmp_ds [lindex [$AdminConfig showAttribute $cmp_cf cmpDatasource] 0] if { [string compare $cmp_ds $ds_to_remove] == 0 } { puts "Found CMPConnectorFactory for data source $ds_to_remove" puts "Removing the CMPConnectorFactory '$cmp_cf'" $AdminConfig remove $cmp_cf puts "'$cmp_cf' is removed." break } } puts "Removing the data source '$ds_to_remove'" $AdminConfig remove $ds_to_remove puts "'$ds_to_remove' is removed." #$AdminConfig save
- The createDatasource command will not complete successfully if you are creating a data source on a JDBC provider that does not exist or does not contain the providerType attribute. This error can be caused if created the JDBC provider with the AdminConfig create JDBCProvider method of the JMX API. This method creates the JDBC provider, but it does not add a providerType attribute.
The createDatasource command will issue the following error:
"ADMF0006E: Step configureResourceProperties of command createDatasource is not found"
To resolve this issue, use commands from the JDBCProviderManagement group, which provides the AdminTask commands createJDBCProvider and createDatasource. The AdminTask commands are designed to be used together.
The AdminConfig JMX API methods "create JDBCProvider" and "create Datasource," which support Version 5.1 and later, are also designed to be used together. Scripts that use the JMX API methods should not use the AdminTask commands.
- The createDatasource command will not complete successfully if the JDBC provider object ID, which specified when creating the data source, does not match the ID of the JDBC provider. If the JDBC provider object ID and the ID of the JDBC provider do not match, we can obtain the correct ID from the results of the createJDBCProvider command. Then, specify this ID when you use the createDatasource command. If we have already created the JDBC provider, use the listJDBCProviders command to list the correct ID.
gotcha
createJDBCProvider
The createJDBCProvider command creates a new Java database connectivity provider (JDBC) that we can use to connect to a relational database for data access.
Target object None
Required parameters
- -scope
- The scope for the new JDBC provider. Provide the scope in the form type=name. Type can be Cell, Node, Server, Application, or Cluster, and name is the name of the specific instance of the cell, node, server, application, or cluster that you are using. The default is none. (String, required)
- -databaseType
- The type of database that will be used by the JDBC provider. For example, DB2 , Derby, Informix , Oracle, and so on. (String, required)
- -providerType
- The JDBC provider type that will be used by the JDBC provider. (String, required)
- -implementationType
- The implementation type for this JDBC provider. Use Connection pool data source if the application runs in a single phase or a local transaction. Otherwise, use XA data source to run in a global transaction. (String, required)
Optional parameters
- -classpath
- List of paths or JAR file names that form the location for the resource provider classes. (String, optional)
- -description
- The description for the JDBC provider. (String, optional)
- -implementationClassName
- Specifies the Java class name for the JDBC driver implementation. (String, optional)
- -name
- The name of the JDBC provider. The default is the value from the provider template. (String, optional)
- -nativePath
- List of paths that form the location for the resource provider native libraries. (String, optional)
- -isolated
- Whether the JDBC provider loads within the class loader. The default value is false. We cannot specify a native path for an isolated JDBC provider. (Boolean, optional)
Examples
Batch mode example:
- Jacl:
$AdminTask createJDBCProvider {-scope Cell=my02Cell -databaseType DB2 -providerType "DB2 Universal JDBC Driver Provider" -implementationType "XA data source" -name "DB2 Universal JDBC Driver Provider (XA)"-description "XA DB2 Universal JDBC Driver-compliant Provider. Datasources created under this provider support the use of XA to perform 2-phase commit processing. Use of driver type 2 on WAS z/OS is not supported for datasources created under this provider." -classpath {"${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc.jar;${UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cu.jar; ${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cisuz.jar"} -nativePath {"${DB2UNIVERSAL_JDBC_DRIVER_NATIVEPATH}"}}
- Jython string...
AdminTask.createJDBCProvider('[-scope Cell=myCell -databaseType DB2 -providerType "DB2 Universal JDBC Driver Provider" -implementationType "XA datasource" -name "DB2 Universal JDBC Driver Provider (XA)" -description "XA DB2 Universal JDBC Driver-compliant Provider. Datasources created under this provider support the use of XA to perform 2-phase commit processing. Use of driver type 2 on WAS z/OS is not supported for datasources created under this provider." -classpath ${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc.jar;${UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cu.jar; ${DB2UNIVERSAL_JDBC_DRIVER_PATH}/ db2jcc_license_cisuz.jar -nativePath ${DB2UNIVERSAL_JDBC_DRIVER_NATIVEPATH}]')
- Jython list:
AdminTask.createJDBCProvider(['-scope', 'Cell=myCell', '-databaseType', 'DB2', '-providerType', 'DB2 Universal JDBC Driver Provider', '-implementationType', 'XA data source', '-name', 'DB2 Universal JDBC Driver Provider (XA)', '-description', 'XA DB2 Universal JDBC Driver-compliant Provider. Datasources created under this provider support the use of XA to perform 2-phase commit processing. Use of driver type 2 on WAS z/OS is not supported for datasources created under this provider.', '-classpath', '${DB2UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc.jar; ${UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cu.jar;${DB2UNIVERSAL_JDBC_DRIVER_PATH}/ db2jcc_license_cisuz.jar', '-nativePath', '${DB2UNIVERSAL_JDBC_DRIVER_NATIVEPATH}'])
Interactive mode:
- Jacl:
$AdminTask createJDBCProvider {-interactive}
- Jython:
AdminTask.createJDBCProvider('-interactive')
deleteDatasource
The deleteDatasource command deletes a data source for an existing JDBC Provider at a specific scope.
Target object DataSource Object ID - The configuration object of the DataSource to delete.
Required parameters None.
Optional parameters None.
Examples
Batch mode example:
- Jacl:
$AdminTask deleteDatasource "DB2 Universal JDBC Driver Provider (XA)(cells/myCell|resources.xml #DataSource_1170538153781)"
- Jython string...
AdminTask.deleteDatasource('DB2 Universal JDBC Driver Provider (XA)(cells/myCell|resources.xml# DataSource_1170538153781)')
Result:
The DataSource is deleted at the specific scope. Also, if DataSource is a DB2 data source configured as a Type 4 JDBC driver and enabled for Client Reroute, the JNDI name specified in either the Client reroute server list JNDI name field or the clientRerouteServerListJNDIName data source custom property is unbound.
To save the changes made by the command, invoke the save command of the AdminConfig object. If the changes are not saved, the Client reroute server list JNDI name must be rebound by issuing a test connection on DataSource or by restarting the server.
deleteJDBCProvider
The deleteJDBCProvider command deletes a JDBC provider and its data sources from a specific scope.
Target object JDBCProvider Object ID - The configuration object of the JDBCProvider to delete.
Required parameters None.
Optional parameters None.
Examples
Batch mode example:
- Jacl:
$AdminTask deleteJDBCProvider "DB2 Universal JDBC Driver Provider (XA)(cells/myCell|resources.xml#JDBCProvider_1180538152781)"
- Jython string...
AdminTask.deleteJDBCProvider('DB2 Universal JDBC Driver Provider (XA) (cells/myCell|resources.xml#JDBCProvider_1180538152781)')
Result:
The JDBCProvider is deleted at the specific scope. If JDBCProvider is a DB2 universal database provider, for each data source of JDBCProvider configured as a Type 4 JDBC driver and enabled for Client Reroute, the JNDI name specified in either the Client reroute server list JNDI name field or the clientRerouteServerListJNDIName data source custom property is unbound.
To save the changes made by the command, invoke the save command of the AdminConfig object. If the changes are not saved, the Client reroute server list JNDI names must be rebound by issuing test connections on the data sources of JDBCProvider or by restarting the server.
listDatasources
Use the listDatasources command to list data sources contained in the specified scope.
Target object None
Required parameters None.
Optional parameters
- -scope
- The scope for the data sources that will be listed. Provide the scope in the form type=name. Type can be Cell, Node, Server, Application, or Cluster, and name is the name of the specific instance of the cell, node, server, application, or cluster that you are using. The default is All. (String, optional)
Examples
Batch mode example:
- Jacl:
$AdminTask listDatasources {-scope Cell=my02Cell}
- Jython string...
AdminTask.listDatasources('[-scope Cell=my02Cell]')
- Jython list:
AdminTask.listDatasources('-scope', 'Cell=my02Cell')
Interactive mode:
- Jacl:
$AdminTask listDatasources {-interactive}
- Jython:
AdminTask.listDatasources('-interactive')
listJDBCProviders
The listJDBCProviders command lists JDBC providers contained in the specified scope.
Target object None
Required parameters None.
Optional parameters
- -scope
- The scope for the JDBC providers that will be listed. Provide the scope in the form type=name. Type can be Cell, Node, Server, Application, or Cluster, and name is the name of the specific instance of the cell, node, server, application, or cluster that you are using. The default is All. (String, optional)
Examples
Batch mode example:
- Jacl:
$AdminTask listJDBCProviders {-scope Cell=my02Cell}
- Jython string...
AdminTask.listJDBCProviders('-scope Cell=my02Cell')
- Jython list:
AdminTask.listJDBCProviders(['-scope', 'Cell=my02Cell'])
Interactive mode:
- Jacl:
$AdminTask listJDBCProviders {-interactive}
- Jython:
AdminTask.listJDBCProviders('-interactive')
Related tasks
Use the wsadmin scripting AdminTask object for scripted administration
Commands (AdminTask)