IBM Books

Application Development Guide


SQLJ Programming

DB2 SQLJ support is based on the SQLJ ANSI standard. Refer to the DB2 Java website for a pointer to the ANSI website and other SQLJ resources. This chapter contains an overview of SQLJ programming and information that is specific to DB2 SQLJ support.

The following kinds of SQL constructs may appear in SQLJ programs:

DB2 SQLJ Support

DB2 SQLJ support is provided by the DB2 Software Developer's Kit (DB2 SDK). Along with the JDBC support provided by the DB2 client, DB2 SQLJ support allows you to create, build, and run embedded SQL for Java applications, applets, stored procedures and user-defined functions (UDFs). These contain static SQL and use embedded SQL statements that are bound to a DB2 database.

The SQLJ support provided by the DB2 SDK includes:

For more information on the db2profc and db2profp commands, refer to the Command Reference. For more information on the SQLJ run-time classes, refer to the DB2 Java website .

DB2 SQLJ Restrictions

When you create DB2 applications with SQLJ, you should be aware of the following restrictions:

Some browsers do not yet have support for loading a serialized object from a resource file associated with the applet. You will get the following error message when trying to load the applet Applt in those browsers:

   java.lang.ClassNotFoundException: Applt_SJProfile0

As a work-around, there is a utility which converts a serialized profile into a profile stored in Java class format. The utility is a Java class called sqlj.runtime.profile.util.SerProfileToClass. It takes a serialized profile resource file as input and produces a Java class containing the profile as output. Your profile can be converted using the following command:

   profconv Applt_SJProfile0.ser
 
     or
 
   java sqlj.runtime.profile.util.SerProfileToClass Applt_SJProfile0.ser

The class Applt_SJProfile0.class is created as a result. Replace all profiles in .ser format used by the applet with profiles in .class format.

For an SQLJ applet, you need both db2java.zip and runtime.zip files. If you choose not to package all your applet classes, classes in db2java.zip and runtime.zip into a single Jar file, put both db2java.zip and runtime.zip (separated by a comma) into the archive parameter in the "applet" tag. For those browsers that do not support multiple zip files in the archive tag, specify db2java.zip in the archive tag, and unzip runtime.zip with your applet classes in a working directory that is accessible to your web browser.


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

[ DB2 List of Books | Search the DB2 Books ]