Connecting to DB2 UDB

StepsTo add and configure a new data source name (DSN) for a DRDA service

  1. From your control panel, click on the ODBC Administrator icon to start it.

  2. Select the User DSN or System DSN (recommended) and click Add.

  3. Select the DB2 DRDA driver for your installation.

  4. Click Finish.

The ODBC Administrator provides three dialog boxes in which connectivity, package binding, and other options take place. Each section has a Help button, which provides detailed descriptions of each parameter.

StepsTo configure a data source

  1. Select the General tab and enter the connectivity parameters and test them. Be sure you have consulted your database administrator for the Collection and Package names that are required. (Packages are created in the Bind section that follows.)

    Table D-1 contains the General parameters, with the required parameters indicated by an asterisk (*), for this window:

    Table D-1: General parameters

    Parameter

    Comments

    *Data Source Name

    Type a string that identifies this DB2 data source configuration in the system information. If you are creating a new data source definition, type a unique name of up to 32 characters. If you specify the name of an existing data source definition, the new settings will replace the existing ones.

    Description

    Type an optional descriptive comment for this data source definition.

    *Ip address

    Type the IP (Internet Protocol) address of the machine where the catalog tables are stored. Specify the address using the machine's numeric address (for example, 123.456.78.90) or specify its host name. If you enter a host name, the driver must find this name (with the correct address assignment) in the HOSTS file on the workstation or in a DSN server.

    *TCP Port

    Enter the port number that is assigned to the DB2 server on the machine where the catalog tables are stored. Specify either this port's numeric address or its service name. The default numeric port address varies depending on the OS of the DB2 server machine. For DB2, the default may be 50000. For AS/400, the default is 446.

    If you specify a service name, the driver must find this name (with the correct port assignment) in the SERVICES file on the workstation.

    *Location Name

    This field is valid only if you are connecting to a DB2 database running on OS/390 or AS/400. Type the DB2 location name, using the name defined during the local DB2 installation.

    NoteThis field is disabled if the Database Name field is populated.

    *Collection

    This field is valid only if you are connecting to a DB2 database running on OS/390 or AS/400. Type the name that identifies a group of packages. These packages include the DB2 DRDA driver packages. The default for DB2 is DATADIRECT00, and the default for AS/400 is SYBASE.

    NoteThis field is disabled if the Database Name field is populated.

    *Database Name

    This field is valid only if you are connecting to a DB2 database running on Windows. Type the name of the database to which you want to connect.

    NoteThis field is disabled if the Location Name field is populated.

    *Package

    Enter the name of the package that the driver uses to process static and dynamic SQL for applications that use this data source definition. The default name is DEFxx, where xx is the version number.

    Default User ID

    Not used by ECDA.

    WorkArounds2

    The name of the string key to allow the driver to pad the DB2 char for bit data field with spaces. The value is 131072. To add theWorkArounds2 string key, refer to the procedure “To add the WorkArounds2 String Key”.

  2. After you enter this information, click Test Connect. If the connection fails, check for accurate information.

  3. Select the ODBC Administrator Advanced tab, which contains optional fields that can affect performance and resource use.

    NoteThe default values for the remaining optional parameters should be sufficient for most DRDA installations.

    Enter values for the required parameters, indicated by an asterisk (*).

    Table D-2: Advanced parameters

    Parameter

    Comments

    Add to Create Table

    Use the Add to Create Table option if you want to append the in tablespace clause to create table commands.

    Alternate ID

    Enter a value to be substituted at connect time for the current schema. This sets the default qualifier for unqualified object names in SQL statements. If the attempt to change the current schema fails, the connection fails with "Invalid value for Alternate ID." DB2 permissions should be set to SYSADM. (Not valid for AS/400 V4R5 and V5R1.)

    *WithHold Cursors

    This option needs to be selected for ECDA. It determines whether cursors are preserved or deleted after a commit or rollback.

    *Application Using Threads

    This option is required for ECDA.

  4. Select the Bind tab of the DRDA Driver Setup window to define the package.

    The Bind tab allows you to create the bind packages on the server that will be used by the driver. The Bind tab also allows you to specify the behavior of the package.

    Before the DRDA driver can be used, you must create the required packages and bind them to the DB2 system. The driver will not work properly with any server that does not have the packages created. After the packages are created, you can rebind them with new bind parameters as needed.

    NotePlease consult your DB2 database administrator when attempting to create packages. You will need a login with sufficient authorization to create packages and grant execution privileges. DB2 database administration experience may also be needed to capture and analyze package creation errors.

    Enter values for the required parameters, indicated by an asterisk (*). The default values for the remaining optional parameters should be sufficient for most DRDA installations.

    Table D-3: Bind parameters

    Parameters

    Comments

    *Grant Execute

    Indicate whether or not to grant privileges on the package that you are creating. The default value is grant execute privileges on the package to PUBLIC. You can also specify to whom to grant execute privileges.

    *Isolation Level

    Select the Isolation Level method by which locks are acquired and released by the system. Valid values are:

    • All – prevents any other process from accessing data that your application has read or modified. All read or modified data is locked until the end of the transaction.

    • Change – allows other processes to read from the database. Only modified data is locked until the end of the transaction

    • Cursor Stability (the default) – allows other processes to change a row that your application has read if the cursor is not on the row you want to change. Prevents other processes from changing records that your application has changed until your program commits them or terminates. Prevents your program from reading a modified record that has not been committed by another process.

    • No Commit – allows your program to read modified records even if they have not been committed by another person.

    • Repeatable Read – prevents other processes from changing records that are read or changed by your application (including phantom records) until your program commits them or terminates. Prevents the application from reading modified records that have not been committed by another process. If your program opens the same query during a single unit of work under this isolation level, the results table will be identical to the previous table; however, it can contain updates made by your program.

    *Package Owner

    Type the AuthID assigned to the package. This DB2 AuthID must have authority to execute all the SQL in the package

    *Dynamic Sections

    Type the number of statements that the DB2 Wire Protocol driver package can prepare for a single user. The default is 32. This value determines the maximum cursors or dynamic statements that a single connection may have open simultaneously.

  5. Create a package.

    When you click Create Package, a logon window appears. Enter your user ID and password. Then, click Login.A message appears if the package is created successfully.

A separate package is not needed for each access service; however, if the access service has different characteristics in its parameters that suit it for a specific solution, you can create other packages for other solutions.