db2sqljbind - SQLJ profile binder
db2sqljbind binds Db2® packages for a serialized profile that was previously customized with the db2sqljcustomize command.
Authorization
- DBADM authority
- If the package does not exist, the BINDADD privilege, and one
of the following privileges:
- CREATEIN privilege
- IMPLICIT_SCHEMA authority on the database if the schema name of the package does not exist
- If the package exists:
- ALTERIN privilege on the schema
- BIND privilege on the package
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.
Command syntax
Command parameters
- -help
- Specifies that
db2sqljbind
describes each of the options that it supports. If any other options are specified with -help, they are ignored. - -url
- Specifies the URL for the data server for which the profile is
to be bound. The URL can be a URL for IBM Data Server Driver for JDBC and
SQLJ type 4 connectivity or IBM Data Server Driver for JDBC and
SQLJ type 2 connectivity.
The variable parts of the
-url
value are:- server
- The domain name or IP address of the operating system on which the database server resides.
- port
- The TCP/IP server port number that is assigned to the database server. The default is 446.
- database
- A name for the database server for which the profile is to be customized. If the connection is to a Db2 for z/OS® server, database is the Db2 location name that is defined during installation. All characters in this value must be uppercase characters. You can determine the location name by executing the following SQL statement on the server:
SELECT CURRENT SERVER FROM SYSIBM.SYSDUMMY1;
If the connection is to a Db2 on Linux®, UNIX, and Windows systems server, database is the database name that is defined during installation.
If the connection is to an IBM Cloudscape server, the database is the fully-qualified name of the file that contains the database. This name must be enclosed in double quotation marks ("). For example:"c:/databases/testdb"
- property=value;
- A property for the JDBC connection.
- -datasource JNDI-name
- Specifies the logical name of a DataSource object that was registered with JNDI. The DataSource object represents the data source for which the profile is to be customized. A connection is established to the data source if the -automaticbind or -onlinecheck option is specified as YES or defaults to YES. Specifying -datasource is an alternative to specifying -url. The DataSource object must represent a connection that uses IBM Data Server Driver for JDBC and SQLJ type 4 connectivity.
- -user user-ID
- Specifies the user ID to be used to connect to the data source for binding the package.
- -password password
- Specifies the password to be used to connect to the data source for binding the package.
- -bindoptions options-string
- Specifies a list of options, separated by spaces. These options have the same function as
Db2 precompile and bind options with the
same names. If you are preparing your program to run on a Db2 for z/OS system, specify z/OS options. If you are
preparing your program to run on a Db2 on Linux, UNIX, and Windows systems system, specify Db2 on Linux, UNIX, and Windows systems options.
Notes on bind options:
- Specify VERSION only if the following conditions are true:
- If you are binding a package at a Db2 on Linux, UNIX, and Windows systems system, the system is at Version 8 or later.
- You rerun the translator on a program before you bind the associated package with a new VERSION value.
- The value for STATICREADONLY is YES for servers that support STATICREADONLY, and NO for other servers. When you specify STATICREADONLY YES, Db2 processes ambiguous cursors as if they were read-only cursors. For troubleshooting iterator declaration errors, you need to explicitly specify STATICREADONLY NO, or declare iterators so that they are unambiguous. For example, if you want an iterator to be unambiguously updatable, declare the iterator to implement sqlj.runtime.ForUpdate. If you want an iterator to be read-only, include the FOR READ ONLY clause in SELECT statements that use the iterator.
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.
- Specify VERSION only if the following conditions are true:
- -staticpositioned NO|YES
- For iterators that are declared in the same source file as positioned UPDATE statements that use the iterators, specifies whether the positioned UPDATEs are executed as statically bound statements. The default is NO. NO means that the positioned UPDATEs are executed as dynamically prepared statements. This value must be the same as the -staticpositioned value for the previous db2sqljcustomize invocation for the serialized profile.
- -genDBRM
- Specifies that db2sqljbind generates database request modules
(DBRMs) from the serialized profile, and that db2sqljbind does not
perform remote bind operations.
-genDBRM applies to programs that are to be run on Db2 for z/OS database servers only.
- -DBRMDir directory-name
- When -genDBRM is specified, -DBRMDir specifies the local directory
into which db2sqljbind puts the generated DBRM files. The default
is the current directory.
-DBRMdir applies to programs that are to be run on Db2 for z/OS database servers only.
- -tracefile file-name
- Enables tracing and identifies the output file for trace information. This option should be specified only under the direction of IBM Software Support.
- -tracelevel
- If -tracefile is specified, indicates what to trace while
db2sqljcustomize
runs. The default is TRACE_SQLJ. This option should be specified only under the direction of IBM Software Support. - serialized-profile-name|file-name.grp
- Specifies the names of one or more serialized profiles from which the package is bound. A
serialized profile name is of the following form:
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.program-name_SJProfileIDNumber.ser
You can specify serialized profile names in one of the following ways:- List the names in the db2sqljcustomize command. Multiple serialized profile names must be separated by spaces.
- Specify the serialized profile names, one on each line, in a file with the name file-name.grp, and specify file-name.grp in the db2sqljbind command.
If you specify more than one serialized profile name to bind a single Db2 package from several serialized profiles, you must have specified the same serialized profile names, in the same order, when you ran db2sqljcustomize.
If you specify one or more file-name.grp files, you must have run db2sqljcustomize once with that same list of files. The order in which you specify the files in db2sqljbind must be the same as the order in db2sqljcustomize.
You cannot run db2sqljcustomize on individual files, and then group those files when you run db2sqljbind.
Examples
db2sqljbind -user richler -password mordecai
-url jdbc:db2:⁄⁄server:50000⁄sample -bindoptions "EXPLAIN YES"
pgmname_SJProfile0.ser
Usage notes
Package names produced
by db2sqljbind: The names of the packages that are created
by db2sqljbind
are the names that you specified using
the-rootpkgname or -singlepkgname parameter when you ran db2sqljcustomize
.
If you did not specify -rootpkgname or -singlepkgname, the package
names are the first seven bytes of the profile name, appended with
the isolation level character.
DYNAMICRULES value for db2sqljbind: The DYNAMICRULES bind option determines a
number of run-time attributes for the Db2
package. Two of those attributes are the authorization ID that is used to check authorization, and
the qualifier that is used for unqualified objects. To ensure the correct authorization for
dynamically executed positioned UPDATE and DELETE statements in SQLJ programs,
db2sqljbind
always binds the Db2 packages with the DYNAMICRULES(BIND) option.
You cannot modify this option. The DYNAMICRULES(BIND) option causes the SET CURRENT SQLID statement
and the SET CURRENT SCHEMA statement to have no impact on an SQLJ program,
because those statements affect only dynamic statements that are bound with DYNAMICRULES values
other than BIND.
- Force positioned UPDATE and DELETE statements to execute statically. You can use the -staticpositioned YES option of db2sqljcustomize or db2sqljbind to do this if the cursor (iterator) for a positioned UPDATE or DELETE statement is in the same package as the positioned UPDATE or DELETE statement.
- Fully qualify Db2ƒ table names in positioned UPDATE and positioned DELETE statements.
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.