4 DB2 Driver : DB2 Packages

DB2 Packages
The DB2 driver automatically creates all required DB2 packages the first time it connects to the database. By default, the DB2 packages contain 200 dynamic sections and are created in the NULLID collection (or library). You can override the default number of dynamic sections by setting the DynamicSections property. Similarly, you can override the collection in which the packages are created by setting the PackageCollection property.
NOTES: The initial connection may take a few minutes because of the number and size of the packages that must be created for the connection. Subsequent connections do not incur this delay. When the driver has completed creating packages, it writes the following message to the standard output: DB2 packages created.
In most cases, you do not need to create DB2 packages because the DB2 driver automatically creates them the first time it connects to the database. If you need to explicitly create them, you can create them using any of the following methods:
■
■
■
■
Creating DB2 Packages Using the Package Manager
NOTE: The user ID creating the DB2 packages must have BINDADD privileges on the database. Consult with your database administrator to ensure that you have the correct privileges.
To start the DataDirect DB2 Package Manager, run the DB2PackageManager.bat file (on Windows) or the DB2PackageManager.sh script (on UNIX) located in the lib subdirectory in the product installation directory. The DataDirect DB2 Package Manager dialog box appears.
DataDirect DB2 Package Manager dialog box
Complete the fields in the right pane. Refer to the left pane of the DataDirect DB2 Package Manager for instructions on completing these fields. When you are satisfied with your choices, click the Modify Package button to create the package on the DB2 server.
Creating DB2 Packages Using Connection Properties
NOTE: The user ID creating the DB2 packages must have BINDADD privileges on the database. Consult with your database administrator to ensure that you have the correct privileges.
Table 4-1 lists the connection properties you can use to explicitly create DB2 packages.
PackageCollection=collection_name (where collection_name is the name of the collection or library to which DB2 packages are bound)
DynamicSections=x (where x is a positive integer)
NOTE: To create new DB2 packages on DB2 for Linux/UNIX/Windows, you must use ReplacePackage=true in conjunction with CreateDefaultPackage=true. If a DB2 package already exists, it will be replaced when ReplacePackage=true.
Example: DB2 for Linux/UNIX/Windows
The following URL creates DB2 packages with 400 dynamic sections. If any DB2 packages already exist, they will be replaced by the new ones being created.
jdbc:datadirect:db2://server1:50000;DatabaseName=SAMPLE;
CreateDefaultPackage=TRUE;ReplacePackage=TRUE;DynamicSections=400
Example: DB2 for z/OS and iSeries
The following URL creates DB2 packages with 400 dynamic sections.
jdbc:datadirect:db2://server1:446;LocationName=SAMPLE;
CreateDefaultPackage=TRUE;DynamicSections=400
Creating DB2 Packages Using Package Creation List Files
NOTE: The user ID creating the DB2 packages must have BINDADD privileges on the database. Consult with your database administrator to ensure that you have the correct privileges.
To explicitly create DB2 packages, bind the package creation list files for your operating system on your database server:
installdir/DB2/bind/LUW
installdir/DB2/bind/iSeries
installdir/DB2/bind/zOS
When you bind the list files, if any DB2 packages exist, they will be replaced by the new packages. The list files create DB2 packages that contain 200 dynamic sections and are created in the NULLID collection.
To explicitly create DB2 packages:
1
2
From the directory on the database server where you placed the list and bind files, start the DB2 command-line utility. Use the utility to connect to the database where you want to bind the packages. Connect using the following command:
connect to database_name user authorization_name using password
where:
database_name is the name of the database to which you are connecting.
authorization_name is the name of the user you are authenticating to the server.
password is the user’s password.
3
bind @list_file grant public
where list_file is the name of the list file you want to bind.
Copying the DB2 Packages (z/OS and iSeries)
NOTE: The user ID creating the DB2 packages must have BINDADD privileges on the database. Consult with your database administrator to ensure that you have the correct privileges.
To copy the DB2 packages on z/OS and iSeries operating systems, refer to the instruction file for your operating system:
CfJDBC zOS Manual Package Creation Instructions.txt
installdir\DB2\bind\zOS
CfJDBC AS400 Manual Package Creation Instructions.txt
installdir\DB2\bind\iSeries
The DB2 packages contain 200 dynamic sections.