Transfer the file from your workstation to your iSeries server.
From a command prompt, enter the following commands: ftp <iSeries server name>
<Enter your user ID>
<Enter your password>
cd /home/cujo
put BasicJDBC.java
quit
For these commands to work, you must have a directory
in which to put the file. In the example, /home/cujo is the location, but
you can use any location you want.
Note: It is possible that the FTP
commands mentioned previously may be different for you based on how your server
is set up, but they should be similar. It does not matter how you transfer
the file to your iSeries server
as long as you transfer it into the integrated file system. Tools such as VisualAge® for Java can
fully automate this process for you.
Compile the Java file into a class file. Enter the following
command from the CL command line: java class(com.sun.tools.javac.Main) prop(BasicJDBC)
java BasicJDBC
You can also compile the Java file
from QSH:
cd /home/cujo
javac BasicJDBC.java
QSH automatically ensures that the
tools.jar file can be found. As a result, you do not have to add it to your
classpath. The current directory is also in the classpath. By issuing the
change directory (cd) command, the BasicJDBC.java file is also found.
Note: You
can also compile the file on your workstation and use FTP to send the class
file to your iSeries server
in binary mode. This is an example of Java's ability to run on any platform.
Run
the program by using the following command from either the CL command line
or from QSH:
java BasicJDBC
The output
is as follows:
----------------------
| 1 | Frank Johnson |
| |
| 2 | Neil Schwartz |
| |
| 3 | Ben Rodman |
| |
| 4 | Dan Gloore |
----------------------
There were 4 rows returned.
Output is complete.
Java program completed.