The makefile provided for the Java sample programs is presented below. The makefile will only work if a compatible make executable program is resident on your system in a directory included in your PATH variable. A suitable make utility may be provided by another language compiler. Please read the comment at the beginning of the text of the makefile for more information.
The make commands used to build specific Java sample programs are cited in the sections that follow. There is one change from makefiles normally used for other languages. The make clean command removes all files produced by the java compiler: .java files and core dumps; the make cleanall command removes these files as well as any files produced by the SQLJ translator.
# IBM DB2 Universal Database Version 5 # For AIX, HP-UX, SCO UnixWare 7, Silicon Graphics IRIX, and Solaris # Makefile for DB2 java samples # This makefile will only work if a compatible make executable program is # resident on your system in a directory included in your PATH variable. # Such a make utility may be provided by another language compiler. If you # do not have a compatible make utility you cannot use this makefile, but # you can still compile and run these programs by entering the commands # at the command line, as explained in the README. # To build your applications using this makefile, you can use one of # the following commands: # make all - builds all the programs in this directory # make <prog_name> - builds a program designated by <prog_name> # make clean - removes all files produced by the java compiler # from your working directory (such as .class files) # make cleanall - removes all files from your working directory produced # by both the sqlj translator and java compiler. # This file assumes the DB2 instance path is defined by the variable HOME. # It also assumes that DB2 is installed under the DB2 instance. # If these conditions are not true, redefine DB2INSTANCEPATH DB2INSTANCEPATH = $(HOME) # Use the java compiler CC= javac # To connect to another database update the DATASOURCE variable. # User ID and password are optional. If you want to use them, # update TESTUID with your user ID, and TESTPWD with your password. DATASOURCE=sample TESTUID= TESTPWD= COPY = cp ERASE = rm -f # Note: 'all' contains RunCatUdf, which executes the 'java CatUdf' command, # as this must be run before the 'make Udf' command. all : DB2Appl DB2Applt DB2Stp DB2Udf App Applt Stp CatUdf RunCatUdf Udf DropUdf RunCatUdf : java CatUdf clean : $(ERASE) *.class $(ERASE) core cleanall : clean $(ERASE) App.java $(ERASE) Applt.java $(ERASE) Stp.java $(ERASE) CatUdf.java $(ERASE) Udf.java $(ERASE) DropUdf.java $(ERASE) *.ser # Build and run the following JDBC application with these commands: # # make DB2Appl # java DB2Appl # DB2Appl.class : DB2Appl.java DB2Appl : DB2Appl.class $(CC) DB2Appl.java # After following the setup instructions in the README, you can # build and run the following JDBC applet with these commands: # # make DB2Applt # appletviewer DB2Applt.html # DB2Applt.class : DB2Applt.java DB2Applt : DB2Applt.class $(CC) DB2Applt.java # Build and run the following JDBC stored procedure with these commands: # # make DB2Stp # java DB2Stp # DB2Stp.class : DB2Stp.java DB2Stp : DB2Stp.class $(CC) DB2Stp.java $(ERASE) $(DB2INSTANCEPATH)/sqllib/function/DB2StpSample.class $(COPY) DB2StpSample.class $(DB2INSTANCEPATH)/sqllib/function/DB2StpSample.class # Build and run the following JDBC UDF with these commands: # # make DB2Udf # java DB2Udf # DB2Udf.class : DB2Udf.java DB2Udf : DB2Udf.class $(CC) DB2Udf.java $(ERASE) $(DB2INSTANCEPATH)/sqllib/function/DB2UdfSample.class $(COPY) DB2UdfSample.class $(DB2INSTANCEPATH)/sqllib/function/DB2UdfSample.class # Build and run the following SQLJ application with these commands: # # make App # java App # App.java : App.sqlj sqlj App.sqlj App.class : App.java App_SJProfile0.ser App : App.class $(CC) App.java db2profc -url=jdbc:db2:sample -prepoptions="package using App" App_SJProfile0 # After following the setup instructions in the README, you can # build and run the following SQLJ applet with these commands: # # make Applt # appletviewer Applt.html # Applt.java : Applt.sqlj sqlj Applt.sqlj Applt.class : Applt.java Applt_SJProfile0.ser Applt : Applt.class $(CC) Applt.java db2profc -url=jdbc:db2:sample -prepoptions="package using Applt" Applt_SJProfile0 # Build and run the following SQLJ stored procedure with these commands: # # make Stp # java Stp # Stp.java : Stp.sqlj sqlj Stp.sqlj Stp.class : Stp.java Stp_SJProfile0.ser Stp : Stp.class $(CC) Stp.java db2profc -url=jdbc:db2:sample -prepoptions="package using Stp" Stp_SJProfile0 $(ERASE) $(DB2INSTANCEPATH)/sqllib/function/Stpsrv.class $(ERASE) $(DB2INSTANCEPATH)/sqllib/function/Stp_Cursor1.class $(ERASE) $(DB2INSTANCEPATH)/sqllib/function/Stp_Cursor2.class $(ERASE) $(DB2INSTANCEPATH)/sqllib/function/Stp_SJProfileKeys.class $(ERASE) $(DB2INSTANCEPATH)/sqllib/function/Stp_SJProfile0.ser $(COPY) Stpsrv.class $(DB2INSTANCEPATH)/sqllib/function/Stpsrv.class $(COPY) Stp_Cursor1.class $(DB2INSTANCEPATH)/sqllib/function/Stp_Cursor1.class $(COPY) Stp_Cursor2.class $(DB2INSTANCEPATH)/sqllib/function/Stp_Cursor2.class $(COPY) Stp_SJProfileKeys.class $(DB2INSTANCEPATH)/sqllib/function/Stp_SJProfileKeys.class $(COPY) Stp_SJProfile0.ser $(DB2INSTANCEPATH)/sqllib/function/Stp_SJProfile0.ser # The following SQLJ User-Defined Functions application requires three programs. # Build and run the UDF programs with these commands: # # make CatUdf # java CatUdf # make Udf # java Udf # make DropUdf # java DropUdf # # Note: 'java CatUdf' must be executed before 'make Udf'. The 'make all' # command calls RunCatUdf, which executes 'java CatUdf', before calling Udf. CatUdf.java : CatUdf.sqlj sqlj CatUdf.sqlj CatUdf.class : CatUdf.java CatUdf_SJProfile0.ser CatUdf : CatUdf.class $(CC) CatUdf.java db2profc -url=jdbc:db2:sample -prepoptions="package using CatUdf" CatUdf_SJProfile0 Udf.java : Udf.sqlj sqlj Udf.sqlj Udf.class : Udf.java Udf_SJProfile0.ser Udf : Udf.class $(CC) Udf.java db2profc -url=jdbc:db2:sample -prepoptions="package using Udf" Udf_SJProfile0 $(ERASE) $(DB2INSTANCEPATH)/sqllib/function/Udfsrv.class $(COPY) Udfsrv.class $(DB2INSTANCEPATH)/sqllib/function/Udfsrv.class DropUdf.java : DropUdf.sqlj sqlj DropUdf.sqlj DropUdf.class : DropUdf.java DropUdf_SJProfile0.ser DropUdf : DropUdf.class $(CC) DropUdf.java db2profc -url=jdbc:db2:sample -prepoptions="package using DropUdf" DropUdf_SJProfile0