Set a JDBC provider using scripting


 

+

Search Tips   |   Advanced Search

 

Configure a JDBC provider using wsadmin and scripting.

 

Start wsadmin

Interactively...

$AdminTask createJDBCProvider {-interactive}

AdminTask.createJDBCProvider (['-interactive'])

Non-interactively using the AdminConfig object:

  1. Identify the parent ID and assign it to the node variable.

    The following example uses the node configuration object as the parent. We can modify this example to use the cell, cluster, server, or application configuration object as the parent.

    ### Jacl
    set node [$AdminConfig getid /Cell:mycell/Node:jname/]

    ### Jython
    node = AdminConfig.getid('/Cell:mycell/Node:jname/')
    print node

  2. Identify the required attributes.

    We can script JDBC providers with the templates used by the admin console.

    ### Jacl
    $AdminConfig required JDBCProvider

    ### Jython
    print AdminConfig.required('JDBCProvider')

    Example output...

    Attribute Type name String implementationClassName String

  3. Set up the required attributes and assign it to the jdbcAttrs variable.

    We can modify the following example to setup non-required attributes for JDBC provider.

    With Jacl...

    set jname [list name JDBC1]
    set iclass [list implementationClassName myclass]
    set jdbcAttrs [list $jname $iclass]

    Example output...

    {name {JDBC1}} {implementationClassName {myclass}}

    With Jython..

    jname = ['name', 'JDBC1']
    iclass = ['implementationClassName', 'myclass']
    jdbcAttrs = [jname, iclass]
    print jdbcAttrs

    Example output...

    [['name', 'JDBC1'], ['implementationClassName', 'myclass']]

  4. Create a new JDBC provider using node as the parent:

    $AdminConfig create JDBCProvider $mynode $jdbcAttrs

    AdminConfig.create('JDBCProvider', mynode, jdbcAttrs)

    Example output...

    JDBC1(cells/mycell/nodes/jname|resources.xml#JDBCProvider_1)
  5. Save the configuration changes.
  6. Synchronize the node.

  7. If we have modified a class or native library path, restart each appserver within scope.

 

Related tasks

Use the AdminConfig object for scripted administration
Set new data sources using scripting

 

Related

Commands for the AdminConfig object