IBM Books

Building Applications for UNIX** Environments


JDBC Programs

Applications

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

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

  1. Compile DB2Appl.java with this command:

    javac DB2Appl.java

    to produce the file: DB2Appl.class.

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

makefile. To build this application with the makefile, and then run it:

  1. Ensure your environment includes a compatible make utility as specified in the section "The Java makefile".

  2. Build the application with this command:
    make DB2Appl
    

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

Applets

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

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

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

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

  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 with this command:

    javac DB2Applt.java

    to produce the file DB2Applt.class.

  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 sqllib/java/db2java.zip into the same directory as DB2Applt.class and DB2Applt.html.

  7. On your client machine, start your web browser (which supports 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

makefile. To build this applet with the makefile, and then run it:

  1. Ensure your environment includes a compatible make utility as specified in the section "The Java makefile".

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

  3. Modify the DB2Applt.html file according to the instructions there.

  4. 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
    

  5. Build the applet with this command:
    make DB2Applt
    

  6. 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.

  7. Copy the file sqllib/java/db2java.zip into the same directory as DB2Applt.class and DB2Applt.html.

  8. On your client machine, start your web browser (which supports JDK 1.1) and load DB2Applt.html.

As an alternative to steps (2), (6) and (8), 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

Stored Procedures

DB2Stp demonstrates how to write a dynamic SQL Java stored procedure using the JDBC Application driver to access a DB2 database.

Command Line. To build and run this stored procedure by commands entered at the command line:

  1. Compile DB2Stp.java with this command:

    javac DB2Stp.java

    This will produce the files DB2Stp.class and DB2StpSample.class.

  2. Copy DB2StpSample.class to the sqllib/function directory.

  3. Run the java interpreter on the stored procedure with this command:
    java DB2Stp
    

makefile. To build this stored procedure with the makefile, and then run it:

  1. Ensure your environment includes a compatible make utility as specified in the section "The Java makefile".

  2. Build the stored procedure with this command:
    make DB2Stp
    

  3. Run the java interpreter on the stored procedure with this command:
    java DB2Stp
    

User-Defined Functions

DB2Udf demonstrates implementing dynamic SQL user-defined functions using the JDBC Application driver to access a DB2 database.

Command Line. To build and run this UDF program by commands entered at the command line:

  1. Compile DB2Udf.java with this command:

    javac DB2Udf.java

    This will produce the files DB2Udf.class and DB2UdfSample.class.

  2. Copy DB2UdfSample.class to the sqllib/function directory.

  3. Run the java interpreter on the UDF program with this command:
    java DB2Udf
    

makefile. To build this UDF program with the makefile, and then run it:

  1. Ensure your environment includes a compatible make utility as specified in the section "The Java makefile".

  2. Build the UDF program with this command:
    make DB2Udf
    

  3. Run the java interpreter on the UDF program with this command:
    java DB2Udf
    


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

[ DB2 List of Books | Search the DB2 Books ]