db2sqljcustomize processes an SQLJ profile, which contains embedded SQL statements.
By default, db2sqljcustomize produces four DB2® packages: one for each isolation level. db2sqljcustomize augments the profile with DB2-specific information for use at run time.
The user also needs all privileges that are required to compile any static SQL statements in the application. Privileges that are granted to groups are not used for authorization checking of static statements.
>>-db2sqljcustomize--+--------+---------------------------------> '- -help-' >--+--------------------------------------------------------------------------+--> +- -url--jdbc:db2://server-+---------+-/database-+-----------------------+-+ | '-:--port-' | .-----------------. | | | | V | | | | '-:---property=value;-+-' | '- -datasource--JNDI-name--------------------------------------------------' >--+-----------------+--+----------------------+----------------> '- -user--user-ID-' '- -password--password-' .- -automaticbind--YES-. >--+----------------------+--+--------------------------+-------> '- -automaticbind--NO--' +- -pkgversion--AUTO-------+ '- -pkgversion--version-id-' >--+-------------------------------------+----------------------> '- -bindoptions--"--options-string--"-' >--+--------------------+--+-------------------------------+----> '- -storebindoptions-' '- -collection--collection-name-' .- -onlinecheck--YES-. >--+--------------------+--+-----------------------------+------> '- -onlinecheck--NO--' '- -qualifier--qualifier-name-' >--+----------------------------------+--+---------------+------> +- -rootpkgname--package-name-stem-+ '- -longpkgname-' '- -singlepkgname--package-name----' .- -staticpositioned--NO--. >--+-------------------------+----------------------------------> '- -staticpositioned--YES-' >--+------------------------------------------------------------------------------+--> | .- -tracelevel--TRACE_SQLJ-------------------------. | '- -tracefile--file-name--+--------------------------------------------------+-' | .-,------------------------------. | | V | | '- -tracelevel----+-TRACE_NONE-----------------+-+-' +-TRACE_CONNECTION_CALLS-----+ +-TRACE_STATEMENT_CALLS------+ +-TRACE_RESULT_SET_CALLS-----+ +-TRACE_DRIVER_CONFIGURATION-+ +-TRACE_CONNECTS-------------+ +-TRACE_DRDA_FLOWS-----------+ +-TRACE_RESULT_SET_META_DATA-+ +-TRACE_PARAMETER_META_DATA--+ +-TRACE_DIAGNOSTICS----------+ +-TRACE_SQLJ-----------------+ +-TRACE_XA_CALLS-------------+ +-TRACE_TRACEPOINTS----------+ '-TRACE_ALL------------------' >--+--------------------+---------------------------------------> '- -zosDescProcParms-' >--+------------------------------------+--+-----------+--------> '- -zosProcedurePath--procedure-path-' '- -genDBRM-' >--+---------------------------+--------------------------------> '- -DBRMDir--directory-name-' .-----------------------------. V | >----+-serialized-profile-name-+-+----------------------------->< '-file-name.grp-----------'
SELECT CURRENT SERVER FROM SYSIBM.SYSDUMMY1;
If the connection is to a DB2 for Linux, UNIX, and Windows server, database is the database name that is defined during installation.
"c:/databases/testdb"
The default is YES.
The number of packages and the isolation levels of those packages are controlled by the -rootpkgname and -singlepkgname options.
The default is that there is no version.
Important: Specify only those program preparation options that are appropriate for the data source at which you are binding a package. Some values and defaults for the IBM Data Server Driver for JDBC and SQLJ are different from the values and defaults for DB2.
If -longpkgname is not specified, package-name-stem must be an alphanumeric string of seven or fewer bytes.
If -longpkgname is specified, package-name-stem must be an alphanumeric string of 127 or fewer bytes.
If -longpkgname is not specified, package-name must be an alphanumeric string of eight or fewer bytes.
If -longpkgname is specified, package-name must be an alphanumeric string of 128 or fewer bytes.
Using the -singlepkgname option is not recommended.
Recommendation: If the target data source is DB2 for z/OS, use uppercase characters for the package-name-stem or package-name value. DB2 for z/OS systems that are defined with certain CCSID values cannot tolerate lowercase characters in package names or collection names.
If you do not specify -rootpkgname or -singlepkgname, db2sqljcustomize generates four package names that are based on the serialized profile name. A serialized profile name is of the following form:
program-name_SJProfileIDNumber.ser
Bytes-from-program-nameIDNumberPkgIsolation
Table 1 shows the parts of a generated
package name and the number of bytes for each part. Package name part | Number of bytes | Value |
---|---|---|
Bytes-from-program-name | m=min(Length(program-name), maxlen–1–Length(IDNumber)) | First m bytes of program-name, in uppercase |
IDNumber | Length(IDNumber) | IDNumber |
PkgIsolation | 1 | 1, 2, 3, or 4. This value represents the transaction isolation level for the package. See Table 2. |
Table 2 shows the values of the PkgIsolation portion of a package name that is generated by db2sqljcustomize.
PkgNumber value | Isolation level for package |
---|---|
1 | Uncommitted read (UR) |
2 | Cursor stability (CS) |
3 | Read stability (RS) |
4 | Repeatable read (RR) |
THIS1111
THIS1112
THIS1113
THIS1114
THISISMYPROG1111
THISISMYPROG1112
THISISMYPROG1113
THISISMYPROG1114
A01
A02
A03
A04
Letting db2sqljcustomize generate package names is not recommended. If any generated package names are the same as the names of existing packages, db2sqljcustomize overwrites the existing packages. To ensure uniqueness of package names, specify -rootpkgname.
-zosDescProcParms applies only to programs that run on DB2 for z/OS data servers.
If -zosDescProcParms is specified, and the authorization ID under which db2sqljcustomize runs does not have read access to the SYSIBM.SYSROUTINES catalog table, db2sqljcustomize returns an error and uses the host variable data types in the CALL statements to determine the SQL data types.
Specification of -zosDescProcParms can lead to more efficient storage usage at run time. If SQL data type information is available, SQLJ has information about the length and precision of INOUT and OUT parameters, so it allocates only the amount of memory that is needed for those parameters. Availability of SQL data type information can have the biggest impact on storage usage for character INOUT parameters, LOB OUT parameters, and decimal OUT parameters.
When -zosDescProcParms is specified, the DB2 data server uses the specified or default value of -zosProcedurePath to resolve unqualified names of stored procedures for which SQL data type information is requested.
If -zosDescProcParms is not specified, db2sqljcustomize uses the host variable data types in the CALL statements to determine the SQL data types. If db2sqljcustomize determines the wrong SQL data type, an SQL error might occur at run time. For example, if the Java™ host variable type is String, and the corresponding stored procedure parameter type is VARCHAR FOR BIT DATA, an SQL run-time error such as -4220 might occur.
-zosProcedurePath applies to programs that are to be run on DB2 for z/OS database servers only.
SYSIBM, SYSFUN, SYSPROC, procedure-path, qualifier-name, user-ID
qualifier-name is
the value of the -qualifier parameter, and user-ID is
the value of the -user parameter.The DB2 data server tries the schema names in the SQL path from left to right until it finds a match with the name of a stored procedure that exists on that database server. If the DB2 data server finds a match, it obtains the information about the parameters for that stored procedure from the DB2 catalog. If the DB2 data server does not find a match, SQLJ sets the parameter data without any DB2 catalog information.
SYSIBM, SYSFUN, SYSPROC, qualifier-name, user-ID
If
the -qualifier parameter is not specified, the SQL path does not include qualifier-name.-genDBRM applies to programs that are to be run on DB2 for z/OS database servers only.
If -genDBRM and -automaticbind NO are specified, db2sqljcustomize creates the DBRMs but does not bind them into DB2 packages. If -genDBRM and -automaticbind YES are specified, db2sqljcustomize creates the DBRMs and binds them into DB2 packages.
One DBRM is created for each DB2 isolation level. The naming convention for the generated DBRM files is the same as the naming convention for packages. For example, if -rootpkgname SQLJSA0 is specified, and -genDBRM is also specified, the names of the four DBRM files are:-DBRMdir applies to programs that are to be run on DB2 for z/OS database servers only.
program-name_SJProfileIDNumber.ser
You
can specify the serialized profile name with or without the .ser extension.program-name is the name of the SQLJ source program, without the extension .sqlj. n is an integer between 0 and m-1, where m is the number of serialized profiles that the SQLJ translator generated from the SQLJ source program.
If you specify more than one serialized profile name, and if you specify or use the default value of -automaticbind YES, db2sqljcustomize binds a single DB2 package from the profiles. When you use db2sqljcustomize to create a single DB2 package from multiple serialized profiles, you must also specify the -rootpkgname or -singlepkgname option.
If you specify more than one serialized profile name, and you specify -automaticbind NO, if you want to bind the serialized profiles into a single DB2 package when you run db2sqljbind, you need to specify the same list of serialized profile names, in the same order, in db2sqljcustomize and db2sqljbind.
If you specify one or more file-name.grp files, and you specify -automaticbind NO, when you run db2sqljbind, you must specify that same list of files, and in the same order in which the files were customized.
You cannot run db2sqljcustomize on individual files, and then group those files when you run db2sqljbind.
When db2sqljcustomize runs, it creates a customized serialized profile. It also creates DB2 packages, if the automaticbind value is YES.
db2sqljcustomize -user richler -password mordecai
-url jdbc:db2:⁄server:50000⁄sample -collection duddy
-bindoptions "EXPLAIN YES" pgmname_SJProfile0.ser
Unlike character variables in other host languages, Java String host variables are not declared with a length attribute. To optimize a query properly that contains character host variables, DB2 needs the length of the host variables. For example, suppose that a query has a predicate in which a String host variable is compared to a CHAR column, and an index is defined on the CHAR column. If DB2 cannot determine the length of the host variable, it might do a table space scan instead of an index scan. Online checking avoids this problem by providing the lengths of the corresponding character columns.
Without online checking, DB2 might issue a bind error (SQLCODE -134) when it encounters a predicate in which a String host variable is compared to a GRAPHIC column.
Without online checking, the driver cannot determine the column names for the result table of a remote SELECT.
Customizing multiple serialized profiles together: Multiple serialized profiles can be customized together to create a single DB2 package. If you do this, and if you specify -staticpositioned YES, any positioned UPDATE or DELETE statement that references a cursor that is declared earlier in the package executes statically, even if the UPDATE or DELETE statement is in a different source file from the cursor declaration. If you want -staticpositioned YES behavior when your program consists of multiple source files, you need to order the profiles in the db2sqljcustomize command to cause cursor declarations to be ahead of positioned UPDATE or DELETE statements in the package. To do that, list profiles that contain SELECT statements that assign result tables to iterators before profiles that contain the positioned UPDATE or DELETE statements that reference those iterators.
Using a customized serialized profile at one data source that was customized at another data source: You can run db2sqljcustomize to produce a customized serialized profile for an SQLJ program at one data source, and then use that profile at another data source. You do this by running db2sqljbind multiple times on customized serialized profiles that you created by running db2sqljcustomize once. When you run the programs at these data sources, the DB2 objects that the programs access must be identical at every data source. For example, tables at all data sources must have the same encoding schemes and the same columns with the same data types.
Using the -collection parameter: db2sqljcustomize stores the DB2 collection name in each customized serialized profile that it produces. When an SQLJ program is executed, the driver uses the collection name that is stored in the customized serialized profile to search for packages to execute. The name that is stored in the customized serialized profile is determined by the value of the -collection parameter. Only one collection ID can be stored in the serialized profile. However, you can bind the same serialized profile into multiple package collections by specifying the COLLECTION option in the -bindoptions parameter. To execute a package that is in a collection other than the collection that is specified in the serialized profile, include a SET CURRENT PACKAGESET statement in the program.
Using the VERSION parameter: Use the VERSION parameter to bind two or more versions of a package for the same SQLJ program into the same collection. You might do this if you have changed an SQLJ source program, and you want to run the old and new versions of the program.
It is essential that you specify the VERSION option when you perform this step. If you do not, you overwrite your original packages.
EXTENDEDINDICATOR bind option behavior: If the EXTENDEDINDICATOR bind option is not specified in the -bindoptions options string, and the target data server supports extended indicators, bind operations use EXTENDEDINDICATOR(YES). If EXTENDEDINDICATOR(NO) is explicitly specified, and the application contains extended indicator syntax, unexpected behavior can occur because the IBM Data Server Driver for JDBC and SQLJ treats extended indicators as NULL values.