Building Applications for UNIX** Environments
App demonstrates an SQLJ application that accesses a DB2
database.
Command Line. To build and run this application by
commands entered at the command line:
- Translate App.sqlj with this command:
sqlj App.sqlj
This will produce the files App.java and
App_SJProfile0.ser.
- Compile App.java with this command:
javac App.java
This will produce the files: App.class,
App_Cursor1.class, App_Cursor2.class and
App_SJProfileKeys.class.
- Customize the generated profile and create the package App in
the sample database with this command:
db2profc -url=jdbc:db2:sample prepoptions="package using App" App_SJProfile0
- Run the application with this command:
java App
makefile. To build this application with the
makefile, and then run it:
- Ensure your environment includes a compatible make utility as specified in
the section "The Java makefile".
- Build the application with this command:
make App
- Run the application with this command:
java App
Applt demonstrates an SQLJ applet that accesses a DB2
database.
Command Line. To build and run this applet by commands
entered at the command line:
- Ensure that a web server is installed on your DB2 machine (server or
client).
- Modify the Applt.html file according to the instructions
there.
- Start the JDBC applet server on the TCP/IP port specified in
Applt.html; for example, if in Applt.html,
you specified:
param name=port value='6789'
then you would enter:
db2jstrt 6789
- Translate Applt.sqlj with this command:
sqlj Applt.sqlj
This will produce the files: Applt.java and
Applt_SJProfile0.ser.
- Compile Applt.java with this command:
javac Applt.java
This will produce the files: Applt.class,
Applt_Cursor1.class, Applt_Cursor2.class
and Applt_SJProfileKeys.class.
- Customize the generated profile and create the package Applt in
the sample database with this command:
db2profc -url=jdbc:db2:sample -prepoptions="package using Applt" Applt_SJProfile0
- Ensure that your working directory is accessible by your web
browser. If it is not, copy the following files into a directory that
is accessible:
Applt.html Applt.class,
Applt_Cursor1.class, Applt_Cursor2.class,
Applt_SJProfileKeys.class, Applt_SJProfile0.ser
- Copy the files sqllib/java/db2java.zip and
sqllib/java/runtime.zip into the same directory as your
other Applt files.
- On your client machine, start your web browser (which must support JDK
1.1) and load Applt.html.
As an Alternative to steps (1), (7) and (9), 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 Applt.html
makefile. To build this applet with the
makefile, and then run it:
- Ensure your environment includes a compatible make utility as specified in
the section "The Java makefile".
- Ensure that a web server is installed on your DB2 machine (server or
client).
- Modify the Applt.html file according to the instructions
there.
- Start the JDBC applet server on the TCP/IP port specified in
Applt.html. For example, if in
Applt.html, you specified:
param name=port value='6789'
then you would enter:
db2jstrt 6789
- Build the applet with this command:
make Applt
- Ensure that your working directory is accessible by your web
browser. If it is not, copy the following files into a directory that
is accessible:
Applt.html, Applt.class,
Applt_Cursor1.class, Applt_Cursor2.class,
Applt_SJProfileKeys.class, Applt_SJProfile0.ser
- Copy the files sqllib/java/db2java.zip and
sqllib/java/runtime.zip into the same directory as your
other Applt files.
- On your client machine, start your web browser (which must support JDK
1.1) and load Applt.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 Applt.html
Stp demonstrates an SQLJ stored procedure that accesses a DB2
database.
Command Line. To build and run this stored procedure by
commands entered at the command line:
- Translate Stp.sqlj with this command:
sqlj Stp.sqlj
This will produce the files Stp.java and
Stp_SJProfile0.ser.
- Compile Stp.java with this command:
javac Stp.java
This will produce the files: Stp.class,
Stpsrv.class, Stp_Cursor1.class,
Stp_Cursor2.class and
Stp_SJProfileKeys.class.
- Customize the generated profile and create the package Stp in
the sample database with this command:
db2profc -url=jdbc:db2:sample -prepoptions="package using Stp" Stp_SJProfile0
- Copy these files to the sqllib/function directory:
Stpsrv.class, Stp_Cursor1.class,
Stp_Cursor2.class, Stp_SJProfileKeys.class
and Stp_SJProfile0.ser.
- Run the stored procedure with this command:
java Stp
makefile. To build this stored procedure with the
makefile, and then run it:
- Ensure your environment includes a compatible make utility as specified in
the section "The Java makefile".
- Build the stored procedure with this command:
make Stp
- Run the stored procedure with this command:
java Stp
The sqllib/samples/java directory includes a UDF
application consisting of three SQLJ programs:
- CatUdf demonstrates cataloging Java user-defined functions
(UDFs) and creating a sample table, udftest, for testing
them.
- Udf demonstrates calling Java UDFs against the sample table,
udftest.
- DropUdf demonstrates dropping Java UDFs and the sample table,
udftest.
CatUdf.
Command Line. To build and run this SQLJ program by commands entered at the
command line:
- Translate CatUdf.sqlj with this command:
sqlj CatUdf.sqlj
This will produce the files CatUdf.java and
CatUdf_SJProfile0.ser.
- Compile CatUdf.java with this command:
javac CatUdf.java
This will produce the files CatUdf.class and
CatUdf_SJProfileKeys.class.
- Customize the generated profile and create the package CatUdf
in the sample database with this command:
db2profc -url=jdbc:db2:sample -prepoptions="package using CatUdf" CatUdf_SJProfile0
- Run CatUdf with this command:
java CatUdf
- Next, run the Udf program.
makefile. To build and run this SQLJ program with the
makefile:
- Ensure your environment includes a compatible make utility as specified in
the section "The Java makefile".
- Build and run CatUdf with this command:
make CatUdf
- Next, run the Udf program.
Udf.
Command Line. To build and run this SQLJ program by commands entered at the
command line:
- Translate Udf.sqlj with this command:
sqlj Udf.sqlj
This will produce the files Udf.java and
Udf_SJProfile0.ser.
- Compile Udf.java with this command:
javac Udf.java
This will produce the files: Udf.class,
Udf_Cursor1.class, Udf_Cursor2.class,
Udf_Cursor4.class, Udf_Cursor5.class,
Udf_SJProfileKeys.class and
Udfsrv.class.
Note: | There is no file Udf_Cursor3.class.
|
- Customize the generated profile and create the package Udf in
the sample database with this command:
db2profc -url=jdbc:db2:sample -prepoptions="package using Udf" Udf_SJProfile0
- Copy the Udfsrv.class file into
sqllib/function.
- Run Udf with this command:
java Udf
- Next, run the DropUdf program.
makefile. To build this SQLJ program with the makefile, and then
run it:
- Ensure your environment includes a compatible make utility as specified in
the section "The Java makefile".
- Build Udf with this command:
make Udf
- Run Udf with this command:
java Udf
- Next, run the DropUdf program.
DropUdf.
Command Line. To build and run this SQLJ program by commands entered at the
command line:
- Translate DropUdf.sqlj with this command:
sqlj DropUdf.sqlj
This will produce the files DropUdf.java and
DropUdf_SJProfile0.ser.
- Compile DropUdf.java with this command:
javac DropUdf.java
This will produce the files: DropUdf.class and
DropUdf_SJProfileKeys.class.
- Customize the generated profile and create the package DropUdf
in the sample database with this command:
db2profc -url=jdbc:db2:sample -prepoptions="package using DropUdf"
DropUdf_SJProfile0
- Run DropUdf with this command:
java DropUdf
makefile. To build this SQLJ program with the makefile, and then
run it:
- Ensure your environment includes a compatible make utility as specified in
the section "The Java makefile".
- Build DropUdf with this command:
make DropUdf
- Run DropUdf with this command:
java DropUdf
[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]
[ DB2 List of Books |
Search the DB2 Books ]