Runtime environment for Java routines

For Java routines, the startup procedure for the stored procedure address space contains a JAVAENV DD statement. This statement specifies a data set that contains Language Environment® runtime options for the routines that run in the stored procedure address space.

Create the data set for the runtime options with the characteristics that are listed in the following table.
Option Value
Primary space allocation 1 block
Secondary space allocation 1 block
Record format VB
Record length 255
Block size 4096
After you create the data set, edit it to insert a Language Environment options string, which has this form:
Read syntax diagramSkip visual syntax diagramXPLINK(ON),STACK,STACK64,ENVAR(,"environment-variable=setting"),MSGFILE(ddname,recfm,lrecl,blksize,NOENQENQ)

The maximum length of the Language Environment runtime options string in a JAVAENV data set for Java stored procedures is 245 bytes. If you exceed the maximum length, Db2 truncates the contents but does not issue a message. If you enter the contents of the JAVAENV data set on more than one line, Db2 concatenates the lines to form the runtime options string. The runtime options string can contain no leading or trailing blanks. Within the string, only blanks that are valid within an option are permitted.

If your environment variable list is long enough that the JAVAENV content is greater than 245 bytes, you can put the environment variable list in a separate data set in a separate file, and use the environment variable _CEE_ENVFILE to point to that file.

The descriptions of the parameters are:
_CEE_ENVFILE
Specifies a z/OS® UNIX System Services data set that contains some or all of the settings for environment variables.

Use the _CEE_ENVFILE parameter if the length of environment variable string causes the total length of the JAVAENV content to exceed 245 bytes, which is the Db2 limit for the JAVAENV content.

The data set must be variable-length.The format for environment variable settings in this data set is:
environment-variable-1=setting-1
environment-variable-2=setting-2environment-variable-n=setting-n

You can specify some of your environment variable settings as arguments of ENVAR and put some of the settings in this data set, or you can put all of your environment variable settings in this data set.

For example, to use file /u/db2c10/javasp/jspnolimit.txt for environment variable settings, specify:
_CEE_ENVFILE=/u/db2c10/javasp/jspnolimit.txt
ENVAR
Sets the initial values for specified environment variables. The environment variables that you might need to specify are:
CLASSPATH
When you prepare your Java routines, if you do not put your routine classes into JAR files, include the directories that contain those classes. For example:
CLASSPATH=.:/U/DB2RES3/ACMEJOS 
Do not include directories for JAR files for JDBC or the JDK in the CLASSPATH. If you use a DB2JccConfiguration.properties file, you need to include the directory that contains that file in the CLASSPATH.
DB2_BASE
The value of DB2_BASE is the highest-level directory in the set of HFS directories that contain Db2 for z/OS code.
For example:
DB2_BASE=/usr/lpp/db2c10/base
The default is /usr/lpp/db2c10/base.
JAVA_HOME
This environment variable indicates to Db2 that the WLM environment is for Java routines. The value of JAVA_HOME is the highest-level directory in the set of directories that contain the SDK for Java. For example:
JAVA_HOME=/usr/lpp/java/IBM/J6.0
JCC_HOME
The value of JCC_HOME is the highest-level directory in the set of directories that contain the JDBC driver. For example:
JCC_HOME=/usr/lpp/db2c10/jdbc

JCC_HOME must be set.

JDBCSTD
Specifies which version of the IBM® Data Server Driver for JDBC and SQLJ that Java routines use. Possible values are:
3
Java routines use the version of the driver that supports JDBC 3.0.
4
Java routines use the version of the driver that supports JDBC 4.0.

To run multiple Java stored procedures concurrently in a 64-bit JVM, you must set JDBCSTD to 4.

JVM_DEBUG_PORTRANGE
This environment variable specifies a range of ports that the JVM listens on for debug connections, in the form low-port-number::high-port-number. The default is ports 8000 to 8050. For example:
JVM_DEBUG_PORTRANGE=8051::8055
Specify JVM_DEBUG_PORTRANGE only for WLM environments that are used for debugging Java routines.
JVMPROPS
This environment variable specifies the name of a z/OS UNIX System Services file that contains startup options for the JVM in which the stored procedure runs. For example:
JVMPROPS=/usr/lpp/java/properties/jvmsp
The following example shows the contents of a startup options file that you might use for a JVM in which Java stored procedures run:
  # Properties file for JVM for Java stored procedures
  # Sets the initial size of middleware heap within non-system heap
  -Xms64M

  # Sets the maximum size of nonsystem heap
  -Xmx128M

  #initial size of system heap
  -Xinitsh512K
For information about JVM startup options, see IBM 31-bit and 64-bit SDKs for z/OS, Java 2 Technology Edition, Version 5 SDK and Runtime Environment User Guide, available at:
http://www.ibm.com/servers/eserver/zseries/software/java
Click the Reference Information link.
LC_ALL
Modify LC_ALL to change the locale to use for the locale categories when the individual locale environment variables specify locale information. This value needs to match the CCSID for the Db2 subsystem on which the stored procedures run. For example:
LC_ALL=En_US.IBM-037
TZ
Modify TZ to change the local timezone. For example:
TZ=PST08
The default is GMT (UTC).
USE_LIBJVM_G
Specifies whether the debug version of the JVM is used instead of the default, non-debug version of the JVM. The debug version of the JVM is in dynamic link library libjvm_g. If USE_LIBJVM_G is not specified, or its value is anything other than the capitalized string YES, the non-debug version of the JVM is used. For example, USE_LIBJVM_G=NO causes the non-debug version of the JVM to be used.

If USE_LIBJVM_G=YES, the JVMPROPS environment variable must specify a file that contains JVM startup options. That file must contain the startup option -Djava.execsuffix=_g.

Specify USE_LIBJVM_G=YES only under the direction of IBM Software Support.

WORK_DIR
Modify WORK_DIR to change the default destination for STDOUT and STDERR output.
MSGFILE
Specifies the DD name of a data set in which Language Environment puts runtime diagnostics. All subparameters in the MSGFILE parameter are optional. The default is
MSGFILE(SYSOUT,FBA,121,0,NOENQ)
If you specify a data set name in the JSPDEBUG statement of your stored procedure address space startup procedure, you need to specify JSPDEBUG as the first parameter. If the NUMTCB value in the stored procedure address space startup procedure is greater than 1, you need to specify ENQ as the fifth subparameter. Language Environment run-time options contains complete information about MSGFILE.

Do not specify the MSGFILE parameter in a 64-bit environment.

STACK or STACK64
Controls the allocation of the stack storage of a thread. Specify STACK in a 31-bit environment. Specify STACK64 in a 64-bit environment.
XPLINK(ON)
Causes the initialization of the XPLINK environment. This option must be specified for a 31-bit environment, and should not be specified for a 64-bit environment.

The following example shows the contents of a JAVAENV data set.

ENVAR("JCC_HOME=/usr/lpp/db2c10/jdbc",
"JAVA_HOME=/usr/lpp/java160/J6.0",
"WORK_DIR=/u/db2c10/tmp"),
MSGFILE(JSPDEBUG,,,,ENQ)

For information on environment variables that are related to locales, see z/OS C/C++ Programming Guide.