The following strings include the options used to connect using user ID/password (no encryption) authentication.

Important: To use user ID/ password authentication with encryption, set the Authentication Method option to one of the following values: 1 (Encrypt Password), 2 (Encrypt UID and Password), 7 (Encrypted Password AES), and 8 (Encrypted UID and Password AES). See "Authentication Method" for details.
Note: The strings demonstrated in this section use the DSN-less format. For additional formats, see "Using a connection string".

For Db2 for Linux, UNIX, and Windows; Db2 Hosted; and Db2 Warehouse on Cloud:

DRIVER=DataDirect 8.0 Db2 Wire Protocol;IPAddress=ip_address;TCPPort=tcp_port;
Database=database_name;LogonID=user_name;Password=password;
[attribute=value[;...]];

For Db2 for z/OS and iSeries:

DRIVER=DataDirect 8.0 Db2 Wire Protocol;IPAddress=ip_address;TCPPort=tcp_port;
Location=location_name;Collection=collection_name;LogonID=user_name;Password=password;
[attribute=value[;...]];

where:

ip_address

specifies the host name or the IP address of the machine where catalog tables are stored.

tcp_port

specifies the port number that is assigned to the Db2 DRDA listener process on the server host machine. The default is 50000.

database_name

specifies the name of the database to which you want to connect. Valid only on Db2 for Linux, UNIX, and Windows; Db2 Hosted; and Db2 Warehouse on Cloud.

location_name

specifies the name of the Db2 location that you want to access. Valid only on Db2 for z/OS and Db2 for i.

collection_name

specifies the current collection or library. Valid only on Db2 for z/OS and Db2 for i.

user_name

specifies your username.

password

specifies your password.

attribute=value

specifies connection option settings. Multiple connection option attributes are separated by a semi-colon.

Note: The LogonID and Password options are not required to be stored in the connection string. They can also be sent separately by the application using the SQLConnect ODBC API. For SQLDriverConnect and SQLBrowseConnect, they will need to be specified in the connection string.

The following example connection string includes the options required for connecting to Db2 for Linux, UNIX, and Windows using user ID/password (no encryption) authentication.

DRIVER=DataDirect 8.0 Db2 Wire Protocol;IPAddress=localhost;TCPPort=50000;
Database=db2data;LogonID=jsmith;Password=secret;