ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzamy_5.4.0.1/50/program/datatest.htm

57 lines
4.3 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK rel="stylesheet" type="text/css" href="../../../rzahg/ic.css">
<title>Test the connection</title>
</head>
<BODY>
<!-- Java sync-link -->
<SCRIPT LANGUAGE="Javascript" SRC="../../../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
<h6><a name="datatest"></a>Test the connection</h6>
<p>The test connection service enables developers to test a connection to a data source.</p>
<p>There are several ways to test a connection to a database that uses the parameters defined in a data source in WebSphere Application Server - Express. You can use the administrative console, the wsadmin tool, or a Java stand alone program. All three processes invoke the same methods on the same MBean.</p>
<ul>
<li><p><strong>Administrative console</strong><br>
WebSphere Application Server - Express enables you to test a connection from the administrative console by simply pushing a button. The Data Source Collection and Data Source Details pages have Test Connection buttons. 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. On the collection page, you can select several data sources and test them all at once. Note that there are certain conditions that must be met first.</p>
<p>See <a href="datatestadmin.htm">Testing a connection with the administrative console</a> for more information.</p>
</li>
<li><p><strong>Wsadmin tool</strong><br>
The wsadmin tool provides a scripting interface to a full range of WebSphere Application Server - Express administration activities. Because the Test Connection functionality is implemented as a method on an MBean, and wsadmin can invoke MBean methods, wsadmin can be used to test connections to DataSources. There are three ways to test data source connections from wsadmin:</p>
<ol>
<li><p>Using the testConnection operation in the AdminControl object of wsadmin. This operation tests the configuration properties of a data source object. See <a href="datatestwsadmin.htm">Testing a connection using wsadmin</a> for more information.</p></li>
<li><p>Using the testConnection facility in wsadmin. See <a href="../admin/help/rxml_mtestdata.html">Example: Migrating - Testing the DataSource object connection</a> for more information.</p></li>
<li><p>Invoking the MBean operation. See <a href="../admin/help/rxml_testconnection.html">Example: Testing data source connection using wsadmin</a> for more information.</p></li>
</ol>
</li>
<li><p><strong>Java stand alone program</strong><br>
The test connection commands can also be invoked from a Java program by using Java Management Extensions (JMX) to connect directly to the MBean.</p>
<p>The preferred way of testing connections in WebSphere Application Server - Express is invoking the test connection method through a Java program. The advantage to this method is that you can pass the configuration ID of a configured data source, rather than the properties of the data source. The Java program uses JMX to connect to a running server and invoke the testConnection method on the DataSourceCfgHelper MBean. You connect to the running server, usually on port 8880.</p>
<p>The return value from the invocation is zero (0), a positive number, or an exception. Zero (0) indicates that the operation successfully completed with no warnings. A positive number indicates that the operation successfully completed with the number of warnings. An exception indicates that the test of the connection failed.</p>
<p>See <a href="datatestexconfig.htm">Example: Test a connection using testConnection(ConfigID)</a> for more information about how to invoke the test connection method by passing in the configuration ID of a configured data source.</p>
<p>See <a href="datatestlang.htm">Example: Test a connection using country and language (properties)</a> for more information about how to invoke the test connection operation on the DataSourceCfgHelper MBean from a Java program that wsadmin uses by passing in the properties you want to test.</p>
<p>See <a href="datatestexds.htm">Example: Test a connection to a data source</a> for more information about how to invoke the test connection operations in previous releases of WebSphere Application Server - Express.</p>
</li>
</ul>
</body>
</html>