You can configure new data sources using scripting and the wsadmin
tool.
Before you begin
Before starting this task, the wsadmin tool must be running. See the
Starting the wsadmin scripting client article
for more information.
In WebSphere Application Server, any JDBC driver properties
that are required by your database vendor must be set as data source properties.
Consult the article Data source minimum required settings, by vendor to see a list of these properties and setting
options, ordered by JDBC provider type. Consult your database vendor documentation
to learn about available optional data source properties. Script them as custom
properties after you create the data source. In the Related links section
of this article, click the "Configuring new data source custom properties
using scripting" link for more information.
Procedure
- Using the AdminConfig object to configure a new data source:
- Identify the parent ID, which is the name and location of the
JDBC provider that supports your data source.
Using Jacl:
set newjdbc [$AdminConfig getid /Cell:mycell/Node:mynode/JDBCProvider:JDBC1/]
Using Jython:
newjdbc = AdminConfig.getid('/Cell:mycell/Node:mynode/JDBCProvider:JDBC1/')
print newjdbc
Example output:
JDBC1(cells/mycell/nodes/mynode|resources.xml#JDBCProvider_1)
- Obtain the required attributes.
Using Jacl:
$AdminConfig required DataSource
Using Jython:
print AdminConfig.required('DataSource')
Example output:
Attribute Type
name String
Tip: If the database vendor-required properties
(which are referenced in the article
Data source minimum required settings, by vendor)
are not displayed in the resulting list of required attributes, script these
properties as data source custom properties after you create the data source.
- Set up the required attributes.
Using Jacl:
set name [list name DS1]
set dsAttrs [list $name]
Using Jython:
name = ['name', 'DS1']
dsAttrs = [name]
- Create the data source.
Using Jacl:
set newds [$AdminConfig create DataSource $newjdbc $dsAttrs]
Using Jython:
newds = AdminConfig.create('DataSource', newjdbc, dsAttrs)
print newds
Example output:
DS1(cells/mycell/nodes/mynode|resources.xml#DataSource_1)
- Save the configuration changes. See the Saving configuration changes with the wsadmin tool article for more information.
What to do next
To set additional properties that are supported by your JDBC driver,
script them as data source custom properties.