Test connection

The test connection service enables developers to test a connection to a data source.

There are three ways to test a connection to a database that uses the parameters defined in a data source in the WAS version 5.0.1. Use the administrative console, wsadmin.sh, or a Java stand alone program. All three processes invoke the same methods on the same MBean.


Administrative console

You can test a connection from the administrative console using the Test Connection button on Data Source panels. After you have defined and saved a data source, you can click this button to ensure that the parameters in the data source definition are correct.



wsadmin.sh can be utilized to test connections to DataSources by using $AdminControl testConnection.


Java stand alone program

The test connection commands can also be invoked from a Java program, by using JMX to connect directly to the DataSourceCfgHelper MBean.

The advantage of using a Java program to test connections is that you can pass the configuration ID of a configured data source, rather than the properties of the data source.

The return value from this invocation will be either 0, a positive number, or an exception. 0 indicates that the operation completed successfully, with no warnings. A positive number indicates that the operation completed successfully, with the number of warnings. An exception indicates that the test of the connection failed.