db2sqljbind - SQLJ profile binder

db2sqljbind binds DB2® packages for a serialized profile that was previously customized with the db2sqljcustomize command.

Applications that run with the IBM® Data Server Driver for JDBC and SQLJ require packages but no plans. If the db2sqljcustomize -automaticbind option is specified as YES or defaults to YES, db2sqljcustomize binds packages for you at the data source that you specify in the -url parameter. However, if -automaticbind is NO, if a bind fails when db2sqljcustomize runs, or if you want to create identical packages at multiple locations for the same serialized profile, you can use the db2sqljbind command to bind packages.

Authorization

The privilege set of the process must include one of the following authorities:
  • SYSADM authority
  • DBADM authority
  • If the package does not exist, the BINDADD privilege, and one of the following privileges:
    • CREATEIN privilege
    • PACKADM authority on the collection or on all collections
  • If the package exists, the BIND privilege on the package

Command syntax

>>-db2sqljbind--+--------+-------------------------------------->
                '- -help-'   

>--+-------------------------------------------------------------------------------+-->
   +- -url--+-jdbc:db2://server-+---------+-/database-+--+-----------------------+-+   
   |        |                   '-:--port-'           |  |   .-----------------. | |   
   |        '-jdbc:db2:database-----------------------'  |   V                 | | |   
   |                                                     '-:---property=value;-+-' |   
   '- -datasource--JNDI-name-------------------------------------------------------'   

>-- -user--user-ID-- -password--password------------------------>

>--+-------------------------------------+---------------------->
   '- -bindoptions--"--options-string--"-'   

   .- -staticpositioned--NO--.                  
>--+-------------------------+--+-----------+------------------->
   '- -staticpositioned--YES-'  '- -genDBRM-'   

>--+---------------------------+-------------------------------->
   '- -DBRMDir--directory-name-'   

>--+------------------------------------------------------------------------------+-->
   |                         .- -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------------------'         

   .-----------------------------.   
   V                             |   
>----+-serialized-profile-name-+-+-----------------------------><
     '-file-name.grp-----------'     

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.

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.

-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_SJProfileIDNumber.ser
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.
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 to have no impact on an SQLJ program, because those statements affect only dynamic statements that are bound with DYNAMICRULES values other than BIND.

With DYNAMICRULES(BIND), unqualified table, view, index, and alias names in dynamic SQL statements are implicitly qualified with value of the bind option QUALIFIER. If you do not specify QUALIFIER, DB2 uses the authorization ID of the package owner as the implicit qualifier. If this behavior is not suitable for your program, you can use one of the following techniques to set the correct qualifier:
  • 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.