Connecting to a z/OS host for data set or JES API usage

In order to use the data set or JES APIs on a defined z/OS host, a connection to that z/OS host must first be established.

To connect to a z/OS host for data set or JES API usage:

IZOSHost zosHost = ...
String userID = ...
String password = ...

// use one of the several ZOSCredentialsFactory methods to create a z/OS
// credentials object
IZOSCredentials credentials = ZOSCredentialsFactory
        .createZOSCredentials(userID, password);

// create a connection from the z/OS host
IZOSHostConnection zosHostConnection = zosHost

try {
    // connect to the host

    // the connection is now available for use
} catch (HostCredentialsException e) {
    // credentials were invalid, likely caused by incorrect login
    // information or expired password

When writing plug-ins running in a Workbench for Eclipse client, you may also connect to a z/OS host by using the credentials of the currently logged in Workbench for Eclipse UI user using the ZOSUIUserCredentialsManager:

IZOSHost zosHost = ...

// make sure we have access to the UI user's credentials (either saved
// credentials, or the UI user is currently logged in)
if (!ZOSUIUserCredentialsManager.hasUIUserCredentials(zosHost)) {
    // connect the UI user so we can access their credentials (user will
    // be presented with a login dialog)

// we should have the UI user's credentials now, unless they cancelled
// the login dialog
if (ZOSUIUserCredentialsManager.hasUIUserCredentials(zosHost)) {
    // get UI user's z/OS credentials
    IZOSCredentials credentials = ZOSUIUserCredentialsManager

    // you may now use these credentials to connect to the z/OS Host

Was this page helpful? Yes No Submitting... Thank you