The AS400 object allows special values for system name, user ID, and password when the Java program is running on the Java virtual machine for AS/400.
When you run a program on the Java virtual machine for AS/400, be aware of some special values and other considerations:
1The
Java program cannot set the password to "*current" if you are using
record-level access and V4R3 or earlier. When you use record-level access, "localhost"
is valid for system name and "*current" is valid for user ID;
however, the Java program must supply the password.
*current works only on systems running at Version 4 Release 3 (V4R3) and later. Password and user ID must be specified on system running on V4R2 systems. |
For more information about user ID and password values in the AS/400 environment, see Summary of user ID and password values on an AS400 object.
The following examples show how to use the AS400 object with the Java virtual machine for AS/400.
Example 1: When a Java program is running in the Java virtual machine for AS/400, the program does not have to supply a system name, user ID, or password.
A password must be supplied when using record-level access.
If these values are not supplied, the AS400 object connects to the local system by using the user ID and password of the job that started the Java program.
When the program is running on the Java virtual machine for AS/400, setting the system name to localhost is the same as not setting the system name. The following example shows how to connect to the current AS/400:
// Create two AS400 objects. If the Java program is // running in the Java virtual machine for AS/400, // the behavior of the // two objects is the same. They will connect to the // current AS/400 using the user ID and password of // the job that started the Java program. AS400 sys = new AS400() AS400 sys2 = new AS400("localhost")
Example 2: The Java program can set a user ID and password even when the program is running on the Java virtual machine for AS/400. These values override the user ID and password of the job that started the Java program.
In the following example, the Java program connects to the current AS/400, but the program uses a user ID and password that differs from those of the job that started the Java program.
// Create an AS400 object. Connect to the current // AS/400 but do not use the user ID and password // of the job that started the program. The // supplied values are used. AS400 sys = new AS400("localhost", "USR2", "PSWRD2")
Example 3: A Java program that is running on one AS/400 can connect to and use the resources of other AS/400 systems.
If *current is used for user ID and password, the user ID and password of the job that started the Java program is used when the Java program connects to the target AS/400.
In the following example, the Java program is running on one AS/400, but uses resources from another AS/400. The user ID and password of the job that started the Java program are used when the program connects to the second AS/400.
// Create an AS400 object. This program will run on // one AS/400 but will connect to a second AS/400 // (called "target"). Since *current is used for // user ID and password, the user ID and password // of the job that started the program will be used // when connecting to the second AS/400. // second AS/400. AS400 target = new AS400("target", "*current", "*current")
[ Information Center Home Page | Feedback ] | [ Legal | AS/400 Glossary ] |