WebSphere Application Server Network Deployment, Version 6.0.x   Operating Systems: AIX, HP-UX, Linux, Solaris, Windows
             [TIP: Focusing the table of contents and search results]

Testing data source connections using scripting

You can test connections for data sources with the wsadmin tool and scripting.

Before you begin

Before starting this task, the wsadmin tool must be running. See the Starting the wsadmin scripting client article for more information.

About this task

Perform the following steps to test a data source to ensure a connection to the database.

Procedure

  1. Identify the DataSourceCfgHelper MBean and assign it to the dshelper variable.
    • Using Jacl:
      set ds [$AdminConfig getid /DataSource:DS1/]
      $AdminControl testConnection $ds
    • Using Jython:
      ds = AdminConfig.getid('/DataSource:DS1/')
      AdminControl.testConnection(ds)
    Example output:
    WASX7217I: Connection to provided datasource was successful.
  2. Test the connection. The following example invokes the testConnectionToDataSource operation on the MBean, passing in the classname, userid, password, database name, JDBC driver class path, language, and country.
    • Using Jacl:

      $AdminControl invoke $dshelper testConnectionToDataSource 
      "COM.ibm.db2.jdbc.DB2XADataSource db2admin db2admin 
      {{databaseName sample}} c:/sqllib/java/db2java.zip en US"
    • Using Jython:

      print AdminControl.invoke(dshelper, 'testConnectionToDataSource',  
      'COM.ibm.db2.jdbc.DB2XADataSource dbuser1 dbpwd1 
      "{{databaseName jtest1}}" c:/sqllib/java12/db \"\" \"\"')
    Example output:
    WASX7217I: Connection to provided data source was successful.



Related tasks
Using the AdminControl object for scripted administration
Related reference
Commands for the AdminControl object
Task topic    

Terms of Use | Feedback

Last updated: Mar 8, 2007 8:14:28 PM CST
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.nd.doc/info/ae/ae/txml_testconnection.html

© Copyright IBM Corporation 2004, 2006. All Rights Reserved.
This information center is powered by Eclipse technology. (http://www.eclipse.org)