IBM Books

Building Applications for UNIX** Environments


Building and Running a JDBC Applet

Like other Java applets, JDBC applets are distributed over the Web. Typically, you would embed the applet in an HTML page, as the following steps demonstate. These steps assume that the appropriate port for your platform of the Java Development Kit (JDK) Version 1.1, and at least the client package of DB2, are installed and working.

  1. Run the Java compiler ("javac") on your applet's Java source. For the basic JDBC applet sample, DB2Applt.java, DB2 provides a compiled version in sqllib/samples/java/samples.zip so you may omit this step.

  2. Construct an HTML file that will embed the applet. Unless you hard-code this into the applet source, you may opt to include applet parameters to identify the JDBC applet server, user ID and password information. For DB2Applt.java, DB2 provides the file, DB2Applt.html.

  3. For a larger JDBC applet that consists of several Java classes, you may choose to package all its classes into a single ZIP file. In this case, add your ZIP file into the archive parameter in the "applet" tag. For details, see the JDK Version 1.1 documentation.

  4. Along with the DB2 client package, you must install JDBC applets on a Web server. If necessary, configure the DB2 client package by cataloging remote nodes and/or databases.

  5. Pick an unused TCP/IP port number for use by the JDBC applet server. This is not the TCP/IP port used by the svcename of a DB2 server. Start the server by the db2jstrt program. For example, if you designate port 6789 for JDBC access to your DB2 instance, enter db2jstrt 6789 to start the JDBC applet server.

  6. Copy the embedding HTML file, the JDBC applet's .class or ZIP file, and the sqllib/java/db2java.zip file into a directory under the Web browser's document root. For DB2Applt.java, copy sqllib/samples/java/samples.zip, sqllib/samples/java/DB2Applt.html, and sqllib/java/db2java.zip. You will need to customize this copy of the DB2Applt.html file to identify your Web server, JDBC applet server port number, user ID and password.

  7. You may wish to place the ZIP files into a directory that is shared by several applets that may be loaded from your Web site. In this case, you may need to add a codebase parameter into the "applet" tag in the HTML file to identify that directory. For details, see the JDK Version 1.1 documentation.

  8. To run JDBC applets you must install a Web browser, or other compatible applet viewer, capable of running programs compiled with the JDK Version 1.1.

  9. In the Web browser, open the URL identifying the HTML file at the Web server. The JDBC applet and the JDBC applet driver will be downloaded and executed inside the browser.


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

[ DB2 List of Books | Search the DB2 Books ]