Contents Index Connecting to a data source using a logon dialog box Data types

iAnywhere Solutions ODBC Drivers
  iAnywhere Solutions ODBC Driver for DB2

Connecting to a data source using a connection string


If your application requires a connection string to connect to a data source, you must specify the data source name that tells the driver which section in the system information to use for the default connection information. Optionally, you may specify attribute=value pairs in the connection string to override the default values stored in the system information. These values are not written to the system information.

You can specify either long or short names in the connection string. The connection string has the form:

DSN=data_source_name[;attribute=value[;attribute=value]...]

An example of a connection string for DB2 is:

DSN=DB2MVS;LOC=TESTMVSDB2;UID=JOHN;PWD=XYZZY

To configure a data source in the UNIX environment, you must edit the system information file. This file accepts only long names for attributes.

For more information, see Quick start for UNIX.

The defaults listed in the table are initial defaults that apply when no value is specified in either the connection string or in the data source definition in the system information. If you specified a value for the attribute when configuring the data source, that value is the default.

Most settings can be left at their default values. For a list of key driver settings when using MobiLink, see Key driver settings for MobiLink. For other information, about using ODBC drivers with MobiLink, see http://www.ianywhere.com/developer/technotes/odbc_mobilink.html.

Attribute Description
AddStringTo CreateTable (ASCT) A string that is automatically added to all Create Table statements. This field is primarily for users who need to add an "in database" clause.
AlternateID (AID) This connection string changes the current schema to a user-specified value at connect time. It 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.)
AppCodePage (ACP) AppCodePage has been replaced by IANAAppCodePage (IACP). See below.
Collection (COL) A name that identifies a group of packages. This attribute is valid only if you are connecting to DB2 on OS/390.
Database (DB) The name of the database to which you want to connect.
DataSourceName (DSN) A string that identifies a DB2 data source configuration in the system information. Examples include "Accounting" and "DB2-Serv1".
DynamicSections (DS) The number of statements that the DB2 driver package can prepare for a single user. The initial default is 32.
GrantAuthid (GA) A value that determines to whom execute privileges are granted.

The default value is grant execute privileges on the package to PUBLIC.

GrantExecute (GE) GrantExecute={0|1}. Indicates whether or not to grant privileges on the package that you are creating.

When set to 0, privileges are not granted.

When set to 1, privileges are granted.

IANAAppCodePage (IACP) Valid values for this attribute are listed in Values for IANAAppCodePage Connection String Attribute. The code page that you specify must be the same as the code page used by your application. The driver on UNIX determines the value of the application's code page by checking for an IANAAppCodePage value in the following order:
  • In the connection string

  • In the DataSource section of the system file (odbc.ini)

  • In the ODBC section of the system file (odbc.ini)

If no IANAAppCodePage value is found, the driver uses the default value of 4 (ISO 8859-1 Latin-1).

NOTE: The IANAAppCodePage connection string attribute replaces the AppCodePage connection string attribute in earlier versions of Connect for ODBC. The drivers are backwardly compatible with the AppCodePage attribute, but you must now use the IANAAppCodePage attribute.

IPAddress (IP) The IP address of the machine where the catalog tables are stored. Enter the address using the machine's numeric address (for example, 123.456.78.90) or type its address name. If you enter an address name, the driver must find this name (with the correct address assignment) in the HOSTS file on the workstation or in a DNS server.
IsolationLevel (IL) IsolationLevel={ALL|CHANGE|CURSOR_STABILITY|NO_COMMIT|REPEATABLE_READ}. Specifies the 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    Allows other processes to change a row that your application read if the cursor is not on the row that 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.

IsolationLevel (IL) (cont.) 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.

Location (LOC) A path that specifies the DB2 location name. This attribute is valid and required only if you are connecting to DB2 on OS/390.
LogonID (UID) The default logon ID used to connect to your DB2 database. A logon ID is required only if security is enabled on your database. If so, contact your system administrator to get your logon ID.

For DB2 on UNIX, normal UNIX security is used. The LogonID value is your UNIX user ID.

Package (PCK) 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.
PackageOwner (PO) The AuthID assigned to the package. This DB2 AuthID must have authority to execute all the SQL in the package.
Password (PWD) A password used to connect to your DB2 database.
TcpPort (PORT) The port number that is assigned to the DB2 server on the machine where the catalog tables are stored. Specify this port's numeric address or its name (5179 is the default port address). If you specify a port name, the driver must find this name (with the correct port assignment) in the SERVICES file on the workstation.
WithHold (WH) Set this attribute to 1 for use with MobiLink.

WithHold={0|1}. Specifies the cursor behavior for the application used with this data source. Either DB2 closes all open cursors (Delete cursors) after a commit or rollback, or leaves them open (Preserve cursors). When set to 1, the cursor behavior is Preserve. When set to 0, the cursor behavior is Delete (the default).

If you are using the Static Bind Administrator and you want your package to use cursors WITH HOLD, you must set this attribute to 1. Note that any application using this package must use a data source with this attribute set to 1.

When set to 1, the Static Bind Administrator automatically adds the WITH HOLD clause to queries that it puts in the application's database resource module (DBRM). The WITH HOLD clause prevents DB2 from automatically closing the cursor when the application executes a Commit statement.

SQLGetInfo( ) returns SQL_CB_PRESERVE for SQL_COMMIT_CURSOR_BEHAVIOR
When set to 0, SQLGetInfo( ) returns SQL_CB_DELETE. For information about this function, refer to the Microsoft ODBC API.

Contents Index Connecting to a data source using a logon dialog box Data types