IBM Books

Application Building Guide


JDBC Programs

Applets

DB2Applt demonstrates a dynamic SQL Java applet using the JDBC applet driver to access a DB2 database.

To build and run this applet by commands entered at the command line:

  1. Ensure that a web server is installed and running on your DB2 machine (server or client).

  2. Modify the DB2Applt.html file according to the instructions in the file.

  3. Start the JDBC applet server on the TCP/IP port specified in DB2Applt.html; for example, if in DB2Applt.html, you specified param name=port value='6789', then you would enter:
       db2jstrt 6789
    

  4. Compile DB2Applt.java to produce the file DB2Applt.class with this command:
       javac DB2Applt.java
    

  5. Ensure that your working directory is accessible by your web browser. If it is not, copy DB2Applt.class and DB2Applt.html into a directory that is accessible.

  6. Copy the file %DB2PATH%\java\db2java.zip on OS/2 or Windows 32-bit operating systems, or sqllib/java/db2java.zip on UNIX, into the same directory as DB2Applt.class and DB2Applt.html.

  7. On your client machine, start your web browser (which must support JDK 1.1) and load DB2Applt.html.

As an alternative to steps (1), (5) and (7), you can use the applet viewer that comes with the Java Development Kit by entering the following command in the working directory of your client machine:

   appletviewer DB2Applt.html

You can also use the Java makefile to build this program.

Applications

DB2Appl demonstrates a dynamic SQL Java application using the JDBC Application driver to access a DB2 database.

To build and run this application by commands entered at the command line:

  1. Compile DB2Appl.java to produce the file DB2Appl.class with this command:
       javac DB2Appl.java
    

  2. Run the java interpreter on the application with this command:
       java DB2Appl
    

You can also use the Java makefile to build this program.

Client Applications for Stored Procedures

DB2SpCli is a client application that calls the Java stored procedure, DB2Stp , using the JDBC Application driver. Before building and running this client application, build the stored procedure on the server. See "Stored Procedures".

To build and run this client program by commands entered at the command line:

  1. Compile DB2SpCli.java to produce the file DB2SpCli.class with this command:
       javac DB2SpCli.java
    

  2. Run the java interpreter on the client program with this command:
       java DB2SpCli
    

You can also use the Java makefile to build this program.

Client Applications for User-Defined Functions

UDFcli is the client program that calls the user-defined functions implemented in the user-defined function server program, UDFsrv , using the JDBC application driver. Before building and running this client application, build the user-defined function program, UDFsrv, on the server. See "User-Defined Functions (UDFs)".

To build and run this client program by commands entered at the command line:

  1. Compile UDFcli.java to produce the file UDFcli.class with this command:
       
       javac UDFcli.java
    

  2. Run the java interpreter on the client program with this command:
       java UDFcli
    

You can also use the Java makefile to build this program.

Stored Procedures

DB2Stp demonstrates a dynamic SQL Java stored procedure using the JDBC Application driver. Stored procedures are compiled and stored on a server. When called by a client application, they access the server database and return information to the client application.

To build and run this stored procedure on the server by commands entered at the command line:

  1. Compile DB2Stp.java to produce the file DB2Stp.class with this command:
       javac DB2Stp.java
    

  2. Copy DB2Stp.class to the %DB2PATH%\function directory on OS/2 and Windows 32-bit operating systems, or to the sqllib/function directory on UNIX.

  3. Compile and run the DB2SpCli client application to access the stored procedure. See "Client Applications for Stored Procedures".

You can also use the Java makefile to build this program.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]