Example: Migrating - Testing the DataSource object connection

The following examples demonstrate how to test the connection to a DataSource object in the WAS V4.0 and V6.x:

  • wscp V4.0

    set myds /JDBCDriver:mydriver/DataSource:myds/ 
    DataSource testConnection $myds
    

  • wsadmin V6.x

    The testConnection command is part of the AdminControl object because it is an operational command. This particular type of operational command takes a configuration ID as an argument, so you invoke the getid command on the AdminConfig object:

    Jacl

    set myds [$AdminConfig getid /JDBCProvider:mydriver/DataSource:mydatasrc/] 
    $AdminControl testConnection $myds
    

    Jython

    myds = AdminConfig.getid('/JDBCProvider:mydriver/DataSource:mydatasrc/') 
    AdminControl.testConnection(myds)
    

    In many cases, a user ID and password, or other properties are required to complete the test connection. If this is the case, you receive the following message, which describes the missing properties

    WASX7216E: 2 attributes required for testConnection are missing: "[user, password]" To complete this operation, please supply the missing attributes as an option, following this example: {{user user_val} {password password_val}}
    
    For this example, issue the following commands:

    Jacl

    set myds [$AdminConfig getid /JDBCProvider:mydriver/DataSource:mydatasrc/] 
    $AdminControl testConnection $myds {{user myuser} {password secret}}
    

    Jython

    myds = AdminConfig.getid('/JDBCProvider:mydriver/DataSource:mydatasrc/') 
    AdminControl.testConnection(myds, [['user', 'myuser'], ['password', 'secret']])