Test data source connection using wsadmin

 

 

Using Jacl

### Identify the DataSourceCfgHelper MBean and assign it to the dshelper variable.

set dshelper [$AdminControl queryNames type=DataSourceCfgHelper,process=server,*]


### Test the connection.
$AdminControl invoke $dshelper testConnectionToDataSource \
                               "COM.ibm.db2.jdbc.DB2XADataSource \
                               db2admin \
                               db2admin {{databaseName sample}} \
                               c:/sqllib/java/db2java.jar \
                               en US"

 

Using Jython

### Identify the DataSourceCfgHelper MBean and assign it to the dshelper variable.

dshelper = AdminControl.queryNames('type=DataSourceCfgHelper,process=server*')
print dshelper



### Test the connection.
print AdminControl.invoke(dshelper, \
                          'testConnectionToDataSource',  \
                          'COM.ibm.db2.jdbc.DB2XADataSource \
                          dbuser1 \
                          dbpwd1 "{{databaseName jtest1}}" \
                          /sqllib/java/db \
                          \"\" \"\"')

 

The Preferred Method

Instead of using the method testConnectionToDataSource, use the method testConnection and pass in the configuration ID of the data source. The testConnection method is not available in V5.0. The data source to be tested has to be saved in the master configuration

set myds [$AdminConfig getid "/JDBCProvider:OracleJDBC Driver/DataSource:oracleds/"]

$AdminControl invoke $dshelper testConnection $myds

To aid in making a batch program, the command returns a value instead of a message. A return value of 0 means success. A return value of 1 - n means success, but with a number of warnings. If the process fails, you receive an exception message.