Configure new J2C connection factories using scripting
Use scripting and the wsadmin tool to configure new J2C connection factories. Before starting this task, the wsadmin tool must be running. See the Start the wsadmin scripting client article for more information.
Overview
Perform the following steps to configure a new J2C connection factory:
Procedure
- Identify the parent ID and assign it to the newra variable.
Use Jacl:
set newra [$AdminConfig getid /Cell:mycell/Node:mynode/J2CResourceAdapter:RAR1/]
- Use Jython:
newra = AdminConfig.getid('/Cell:mycell/Node:mynode/J2CResourceAdapter:RAR1/') print newraExample output:
RAR1(cells/mycell/nodes/mynode|resources.xml#J2CResourceAdapter_1)
- There are two ways to configure a new J2C connection factory. Perform one of the following:
- Use the AdminTask object:
- List the connection factory interfaces:
Use Jacl:
$AdminTask listConnectionFactoryInterfaces $newraUse Jacl:
AdminTask.listConnectionFactoryInterfaces(newra)
Example output:
javax.sql.DataSource
- Create a J2CConnectionFactory:
Use Jacl:
$AdminTask createJ2CConnectionFactory $newra { -name cf1 -jndiName eis/cf1 -connectionFactoryInterface avax.sql.DataSourceUse Jacl:
AdminTask.createJ2CConnectionFactory(newra, '['-name', 'cf1', '-jndiName', 'eis/cf1', '-connectionFactoryInterface', 'avax.sql.DataSource']')
Use the AdminConfig object:
- Identify the required attributes:
Use Jacl:
$AdminConfig required J2CConnectionFactory
- Use Jython:
print AdminConfig.required('J2CConnectionFactory')Example output:
Attribute Type connectionDefinition ConnectionDefinition@
- If your resource adapter is JCA1.5 and you have multiple connection definitions defined, it is required specified the ConnectionDefinition attribute. If your resource adapter is JCA1.5 and you have only one connection definition defined, it will be picked up automatically. If your resource adapter is JCA1.0, you do not need to specify the ConnectionDefinition attribute. Perform the following command to list the connection definitions defined by the resource adapter:
Use Jacl:
$AdminConfig list ConnectionDefinition $newra
- Use Jython:
print AdminConfig.list('ConnectionDefinition', $newra)
- Set up the required attributes:
Use Jacl:
set name [list name J2CCF1] set j2ccfAttrs [list $name] set jname [list jndiName eis/j2ccf1]
- Use Jython:
name = ['name', 'J2CCF1'] j2ccfAttrs = [name] jname = ['jndiName', eis/j2ccf1]
- If you are specifying the ConnectionDefinition attribute, also set up the following:
Use Jacl:
set cdattr [list connectionDefinition $cd]
- Use Jython:
cdattr = ['connectionDefinition', $cd]
- Create a J2C connection factory:
Use Jacl:
$AdminConfig create J2CConnectionFactory $newra $j2ccfAttrs
- Use Jython:
print AdminConfig.create('J2CConnectionFactory', newra, j2ccfAttrs)Example output:
J2CCF1(cells/mycell/nodes/mynode|resources.xml#J2CConnectionFactory_1)
Save the configuration changes. See the Saving configuration changes with the wsadmin tool article for more information.
In a network deployment environment only, synchronize the node. See the Synchronizing nodes with the wsadmin tool article for more information.
Use the AdminConfig object for scripted administration
Use the AdminTask object for scripted administration
Related Reference
Commands for the AdminConfig object
Commands for the AdminTask object