Easysoft ODBC-DB2 Driver User's Guide - Configuration

Configuring the Easysoft ODBC-DB2 Driver

The Easysoft ODBC-DB2 Driver is installed on the computer where your applications are running. ODBC applications access ODBC drivers through the ODBC Driver Manager and a data source. The data source tells the Driver Manager which ODBC driver to load, which DB2 server to connect to and how to connect to it. This chapter describes how to create data sources, use DSN-less connections and configure the Easysoft ODBC-DB2 Driver.

Before setting up a data source, you must have successfully installed the Easysoft ODBC-DB2 Driver.

For Easysoft ODBC-DB2 Driver installation instructions, see Installation.

Chapter Guide

Configuring the Easysoft ODBC-DB2 Driver

This section describes how to configure the Easysoft ODBC-DB2 Driver to connect to a DB2 database by using a data source or a DSN-less connection string. The section assumes you are, or are able to consult with, a database administrator.

Refer to the section relevant to your platform to continue:

Setting Up Data Sources on Unix

There are two ways to set up a data source to your DB2 data:

¯ OR ¯

By default, the Easysoft ODBC-DB2 Driver installation creates a SYSTEM data source named [DB2_SAMPLE]. If you are using the unixODBC included in the Easysoft ODBC-DB2 Driver distribution, the SYSTEM odbc.ini file is in /etc.

If you built unixODBC yourself, or installed it from some other source, SYSTEM data sources are stored in the path specified with the configure option --sysconfdir=directory. If sysconfdir was not specified when unixODBC was configured and built, it defaults to /usr/local/etc.

If you accepted the default choices when installing the Easysoft ODBC-DB2 Driver, USER data sources must be created and edited in $HOME/.odbc.ini.


Note

To display the directory where unixODBC stores SYSTEM and USER data sources, type odbcinst -j.

By default, you must be logged in as root to edit a SYSTEM data source defined in /etc/odbc.ini.


You can either edit the sample data source or create new data sources.

Each section of the odbc.ini file starts with a data source name in square brackets [ ] followed by a number of attribute=value pairs.


Note

Attribute names in odbc.ini are not case sensitive.


The Driver attribute identifies the ODBC driver in the odbcinst.ini file to use for a data source.

When the Easysoft ODBC-DB2 Driver is installed into unixODBC, it places an Easysoft ODBC-DB2 entry in odbcinst.ini. For Easysoft ODBC-DB2 Driver data sources therefore, you need to include a Driver = Easysoft ODBC-DB2 entry.

To configure a DB2 data source, in your odbc.ini file, you need to specify:

For example:

 [DB2]

 Driver = Easysoft ODBC-DB2

 Server = my_db2_hostname

 Database = sample

 User = my_os_user

 Password = my_os_password

 

Environment

The Easysoft ODBC-DB2 Driver must be able to find the following shared objects, which are installed during the Easysoft ODBC-DB2 Driver installation:

By default, this is located in /usr/local/easysoft/unixODBC/lib.

By default, this is located in /usr/local/easysoft/lib.

By default, this is located in /usr/local/easysoft/lib.

You may need to set and export LD_LIBRARY_PATH, SHLIB_PATH or LIBPATH (depending on your operating system and run-time linker) to include the directories where libodbcinst.so, libeslicshr.so and libessupp.so are located.


Note

The shared object file extension (.so) may vary depending on the operating system (.so, .a or .sl).


Establishing a Test Connection

The isql query tool lets you test your Easysoft ODBC-DB2 Driver data sources.

To test the Easysoft ODBC-DB2 Driver connection

1.  Change directory into /usr/local/easysoft/unixODBC/bin.

2.  Type ./isql.sh -v data_source, where data_source is the name of the target data source.

3.  At the prompt, type an SQL query. For example:

 SQL> select * from mytable;

¯ OR ¯

 Type help to return a list of tables:

 SQL> help

 

Setting Up Data Sources on Windows

To connect an ODBC application on a Windows machine to a DB2 database:

1.  Open ODBC Data Source Administrator:

 The ODBC Data Source Administrator dialog box is displayed:

Figure 3: The ODBC Data Source Administrator dialog box

2.  Select the User DSN tab to set up a data source that only you can access.

¯ OR ¯

 Select the System DSN tab to create a data source which is available to anyone who logs on to this Windows machine.

3.  Click Add... to add a new data source.

 The Create New Data Source dialog box displays a list of drivers:

Figure 4: The Create New Data Source dialog box

4.  Select Easysoft ODBC-DB2 Driver and click Finish.

 The Easysoft ODBC-DB2 Driver DSN Setup dialog box is displayed:

Figure 5: The Easysoft ODBC-DB2 Driver DSN Setup dialog box

For details of the other attributes that can be set on this dialog box, see Attribute Fields.


64-bit Windows

The Easysoft installer program installs both a 32-bit and a 64-bit version of the Easysoft ODBC-DB2 Driver. If you want to use a 64-bit ODBC application, you need to use the 64-bit Easysoft ODBC-DB2 Driver. If you want to use a 32-bit ODBC application, you need to use the 32-bit Easysoft ODBC-DB2 Driver.

There is both a 32-bit and a 64-bit version of ODBC Administrator. The 64-bit ODBC Administrator is located in Control Panel under Administrative tools. To access the 32-bit ODBC Administrator in Windows 7 and earlier, in the Windows Run dialog box, type:

%windir%\syswow64\odbcad32.exe

On Windows 8, both the 32-bit and 64-bit ODBC Administrator are located in Control Panel under Administrative tools: ODBC Data Sources (32-bit) and ODBC Data Sources (64-bit).

Easysoft ODBC-DB2 Driver data sources created in the 64-bit ODBC Administrator will specify the 64-bit version of the Easysoft ODBC-DB2 Driver. Easysoft ODBC-DB2 Driver data sources created in the 32-bit ODBC Administrator will specify the 32-bit version of the Easysoft ODBC-DB2 Driver.

If you want to create an Easysoft ODBC-DB2 Driver System data source for use with a 64-bit application, use the 64-bit ODBC Administrator. If you want to create an Easysoft ODBC-DB2 Driver System data source for use with a 32-bit application, use the 32-bit ODBC Administrator.

For Easysoft ODBC-DB2 Driver User data sources, it does not matter which version of the ODBC Administrator that you use.


Attribute Fields

This section lists the attributes which can be set for the Easysoft ODBC-DB2 Driver in a table showing:

Attributes which are text fields are displayed as value.

Attributes which are logical fields can contain either 0 (to set to off) or 1 (to set to on) and are displayed as "0|1".

If an attribute can contain one of several specific values then each possible entry is displayed and separated by a pipe symbol.

For example, in the statement:

DIALECT=1|2|3

the value entered may be "1", "2" or "3".

DSN

The name of the User or System data source to be created, as used by the application when calling the SQLConnect or SQLDriverConnect functions.

Interface Value

DSN Dialog Box (Windows)

DSN

odbc.ini file (Unix)

[value]

Connect String

DSN=value

Description

Descriptive text that may be retrieved by certain applications to describe the data source.

Interface Value

DSN Dialog Box (Windows)

Description

odbc.ini file (Unix)

Description=value

Connect String

Not Used

Database

The database to to connect to. For example, to connect to the DB2 SAMPLE database set the Database attribute value to SAMPLE.



Interface Value

DSN Dialog Box (Windows)

Database

odbc.ini file (Unix)

Database = value

Connect String

DATABASE=value

User Name

The operating system user name to use when connecting to DB2. You must specify a name of a user who has access to the machine on which DB2 is running.

To specify the user name in the connection string, use UID rather than User. For more information about specifying Easysoft ODBC-DB2 Driver attributes in the connection string, see DSN-less Connections.



Interface Value

DSN Dialog Box (Windows)

User Name

odbc.ini file (Unix)

User = value

Connect String

USER=value

Password

The password for the user name.

To specify the password in the connection string, use PWD rather than Password.



Interface Value

DSN Dialog Box (Windows)

Password

odbc.ini file (Unix)

Password = value

Connect String

PASSWORD=value

Server

The host name or IP address of the machine on which the DB2 instance is running.

Connection Failover

If your DB2 database is available on more than one DB2 machine, you can define a primary server for the database and additional fallback database servers. By default, the Easysoft ODBC-DB2 Driver will try to connect to the first server that you specify. If that server is unavailable, the Easysoft ODBC-DB2 Driver will try to connect to the next server in the list and so on. Use the format:

Server = primaryserver[:port] [, fallbackserver[:port]...]

where:

For example:

Server = db2hostA,db2hostB,db2hostC:50001

Connection attempts continue until either a connection is successfully made or all the servers in the list have been tried once.

Note that authentication details (as specified by User and Password) needs to be valid on each DB2 machine in the list.

On Unix, if you want to balance the load between database servers, configure the driver to randomly choose the database server it connects to. To do this, set the ClientLB attribute to 1.



Interface Value

DSN Dialog Box (Windows)

Server

odbc.ini file (Unix)

Server = value

Connect String

SERVER = value

Port

The TCP port that the DB2 instance is listening on.

If you are connecting to a default instance that is listening on port 50000, the Port setting can be omitted.



Interface Value

DSN Dialog Box (Windows)

Port

odbc.ini file (Unix)

Port = num

Connect String

PORT=num

IPv6

Set IPv6 to 1 when connecting to a DB2 instance that is listening on an IPv6 address.

By default, IPv6 is OFF (set to 0), which means that the Easysoft ODBC-DB2 Driver assumes that the target DB2 instance is listening on an IPv4 address.



Interface Value

DSN Dialog Box (Windows)

IPv6

odbc.ini file (Unix)

IPv6 = 0|1

Connect String

IPV6=0 | 1

SSL Encryption

Whether the Easysoft ODBC-DB2 Driver requests an encrypted connection to DB2.



Interface Value

DSN Dialog Box (Windows)

Not available.

odbc.ini file (Unix)

Encrypt = 0 | 1

Connect String

ENCRYPT = 0 | 1

Use AES

The encryption algorithm to use when encrypting the user name and password. When ON (set to 1), the Easysoft ODBC-DB2 Driver encrypts the user name and password by using an Advanced Encryption Standard (AES) encryption algorithm. Otherwise, the Easysoft ODBC-DB2 Driver encrypts the user name and password by using a Data Encryption Standard (DES) encryption algorithm.

By default, Use AES is OFF (set to 0).



Interface Value

DSN Dialog Box (Windows)

Use AES

odbc.ini file (Unix)

AESEncAlg = 0 | 1

Connect String

AESENCALG = 0 | 1

Private Key File

The private key for use with the SSL session.



Interface Value

DSN Dialog Box (Windows)

Private Key File

odbc.ini file (Unix)

PrivateKeyFile = value

Connect String

PRIVATEKEYFILE = value

Certificate File

The file that contains the public key certificate of the CA that signed the DB2 certificate. The CA certificate file must be in base-64 PEM format.

If the CA certificate is not installed on your client machine, you need to export the certificate on the DB2 machine and install it on the client.



Interface Value

DSN Dialog Box (Windows)

Certificate File

odbc.ini file (Unix)

CertificateFile = value

Connect String

CERTIFICATEFILE = value

Cypher

The cypher suite that the Easysoft ODBC-DB2 Driver will request during the SSL handshake with the DB2 machine.

A cypher suite is a set of authentication, encryption, and data integrity algorithms used to protect data exchanged between machines. During the SSL handshake part of the connection process, the SSL layer in the ODBC driver and the Schannel layer on the DB2 machine negotiate to decide which cipher suite they will use.

To see which cypher suite is being used for a particular connection, enable Easysoft ODBC-DB2 Driver logging.

Connect and then examine the driver log file. Look for a log file entry similar to:

SSL using cypher 'RC4-MD5 SSLv3 Kx=RSA Au=RSA Enc=RC4(128) Mac=MD5'

This entry shows that the ODBC driver and the DB2 machine negotiated the following cryptographic protection for the connection:

Encryption: RC4

Encryption strength: 128-bit

Cryptographic checksum: MD5

Authentication: RSA

(You can also display the cryptographic settings negotiated during the SSL handshake by enabling Schannel logging. Enable the "Log informational and success events" Schannel logging option to write this information to the Windows Event Viewer logs. For information about how to do this, see http://support.microsoft.com/kb/260729.)

Use the Cypher setting, if you want to request a different encryption or data integrity algorithm to the ones negotiated during the SSL handshake. For example:

Cypher = 3DES+SHA

If you specify a cypher suite that is not available on the server machine, the Easysoft ODBC-DB2 Driver returns the error "Required SSL (failed to receive packet)".

If you specify a cypher suite that the Easysoft ODBC-DB2 Driver does not recognise, the driver returns the error "SSL3_CLIENT_HELLO:no ciphers available".



Interface Value

DSN Dialog Box (Windows)

Cypher

odbc.ini file (Unix)

Cypher = value

Connect String

Cypher = value

Trust Cert

Whether the Easysoft ODBC-DB2 Driver tries to validate the server certificate to verify the identity of the DB2 machine. Set Trust Cert to Yes if your DB2 machine is using a self-signed SSL certificate.



Interface Value

DSN Dialog Box (Windows)

Trust Cert

odbc.ini file (Unix)

TrustServerCertificate = 0 | 1

Connect String

TRUSTSERVERCERTIFICATE = 0 | 1

ClientLB

Whether the Easysoft ODBC-DB2 Driver tries to balance the load between the servers specified by the Server setting. The ClientLB setting only has an effect if you specify a primary server and additional fallback servers with Server.

When ClientLB is ON (set to 1), the Easysoft ODBC-DB2 Driver randomly selects a server to connect to. If the server is unavailable, the Easysoft ODBC-DB2 Driver then moves sequentially through the list of other servers.

When ClientLB OFF (set to 0, the default), the Easysoft ODBC-DB2 Driver tries to connect to the servers in the order that they are defined in. (Primary server first and then each additional fallback server.)

Example

You specify a primary server (db2hostA) and two fallback servers (db2hostB and db2hostC):

Server = db2hostA,db2hostB,db2hostC:1583

When ClientLB is ON, the Easysoft ODBC-DB2 Driver will randomly choose a server to connect to. If, for example, the driver tries to connect to db2hostB first, it will then try to connect to db2hostC (if db2hostB is unavailable) and db2hostA (if sqlsrvhostC is unavailable).

When ClientLB is OFF, the Easysoft driver will try to connect to db2hostA and then db2hostB (if db2hostA is unavailable) and finally db2hostC (if db2hostB is unavailable).



Interface Value

DSN Dialog Box (Windows)

Not available.

odbc.ini file (Unix)

ClientLB = 0 | 1

Connect String

CLIENTLB=0 | 1

RcvBuffer

The size of the receive buffer for the socket in bytes. Possible values for num are:

0, do not set the receive buffer size, use the system default value.

n, where n is a number greater than 0, set the receive buffer to the specified size by passing n to the setsockopt() function .

By default, the system default receive buffer size is used.



Interface Value

DSN Dialog Box (Windows)

Not available.

odbc.ini file (Unix)

RcvBuffer = num

Connect String

RCVBUFFER = num

DPrec

The precision to use when converting SQL_DOUBLE data in a result set to a string

If an application specifies a string as the target type for non-character data in a SQLBindCol or SQLGetData call, the Easysoft ODBC-DB2 Driver converts the data to the target type. Use the DPrec attribute to specify the precision to use when the driver does this conversion for SQL_DOUBLE data.

The default precision is 7.



Interface Value

DSN Dialog Box (Windows)

Not available.

odbc.ini file (Unix)

DPrec = num

Connect String

DPREC = num

FPrec

The precision to use when converting SQL_FLOAT data in a result set to a string

If your application specifies a string as the target type for non-character data in a SQLBindCol or SQLGetData call, the Easysoft ODBC-DB2 Driver converts the data to the target type. Use the FPrec attribute to specify the precision to use when the driver does this conversion for SQL_FLOAT data.

The default precision is 7.



Interface Value

DSN Dialog Box (Windows)

Not available.

odbc.ini file (Unix)

FPrec = num

Connect String

FPREC = num

LimitVarchar

Use LimitVarchar to restrict the size returned by the Easysoft ODBC-DB2 Driver when describing VARCHAR data.



Interface Value

DSN Dialog Box (Windows)

Not available.

odbc.ini file (Unix)

LimitVarchar = num

Connect String

LIMITVARCHAR = num

Locale

The locale on the Easysoft ODBC-DB2 Driver machine.

If you do not set the Locale attribute, the Easysoft ODBC-DB2 Driver will use the value set for the LC_CTYPE environment variable. If LC_CTYPE, is not set, the Easysoft ODBC-DB2 Driver will use the value set for the LANG environment variable. If neither LC_CTYPE nor LANG are set, the Easysoft ODBC-DB2 Driver will set the locale value to C.



Interface Value

DSN Dialog Box (Windows)

Not available.

odbc.ini file (Unix)

Locale = value

Connect String

LOCALE = value

ConvWToUtf

When ON (set to 1), the Easysoft ODBC-DB2 Driver converts strings passed to Unicode ODBC calls (with suffix "W") to UTF-8. The Easysoft ODBC-DB2 Driver also converts metadata and result sets returned by Unicode ODBC calls to UTF-8.

By default, ConvWToUtf is OFF (set to 0).



Interface Value

DSN Dialog Box (Windows)

Not available.

odbc.ini file (Unix)

ConvWToUtf = 0 | 1

Connect String

CONVWTOUTF = 0 | 1

SbUTF8

Controls how single bytes in a string are converted to Unicode. When ON (set to 1), UTF-8 sequences are regarded as single Unicode values. Otherwise, UTF-8 sequences are regarded as individual 8-bit values.

For example, setting SbUTF8 controls whether a UTF-8 Euro symbol (0xE2 0x82 0xAC) converts to 0x20AC (single character) or 0x00E2, 0x0082, 0x00AC (three characters).

By default, SbUTF8 is OFF (set to 0).



Interface Value

DSN Dialog Box (Windows)

Not available

odbc.ini file (Unix)

SbUTF8 = 0 | 1

Connect String

SBUTF8 = 0 | 1

GSSLib

The Easysoft ODBC-DB2 Driver uses libgssapi_krb5.so, the Kerberos GSS-API library, to request service tickets for accessing DB2 instances. If the Easysoft ODBC-DB2 Driver is unable to open this library, the connection will fail with the error:

Krb5: failed to open gss lib (libgssapi_krb5.so)

If the Kerberos GSS-API library is not called libgssapi_krb5.so in your GSS-API distribution, use the GSSLIB attribute in your data source to specify the alternative GSS-API library. For example:

GSSLIB = /opt/extension/lib/libgssapi.so



Interface Value

DSN Dialog Box (Windows)

Not available.

odbc.ini file (Unix)

GSSLib = value

Connect String

GSSLIB = value

GSSFlag

The Easysoft ODBC-DB2 Driver allows you to pass req_flags to the gss_init_sec_context() function, which is used to initiate a security context for the driver. The Key Distribution Center (KDC) uses this security context to verify the identity of the client. To pass req_flags to gss_init_sec_context(), use the GSSFLAG attribute:

GSSFLAG = req_flags

where req_flags is a bitmask specifying the requested GSS services. To look up the available bitmask values, refer to the gssapi.h header file for the GSS-API distribution on the Easysoft ODBC-DB2 Driver machine. The driver default GSSFLAG value is 4, which sets the GSS_C_REPLAY_FLAG flag.

As an example, to request credential delegation, set the GSS_C_DELEG_FLAG flag by including this entry in your data source GSSFLAG = 1.



Interface Value

DSN Dialog Box (Windows)

Not available.

odbc.ini file (Unix)

GSSFlag = req_flags

Connect String

GSSFLAG = req_flags

SingleDB

When ON (set to 1) the Easysoft ODBC-DB2 Driver does not send the database name (the DDM_RDBNAM parameter) in the DRDA authentication message. By default, SingleDB is OFF (set to 0).



Interface Value

DSN Dialog Box (Windows)

Not available.

odbc.ini file (Unix)

SingleDB = 0 | 1

Connect String

SINGLEDB = 0 | 1

DSN-less Connections

In addition to using a data source, you can also connect to a database by using a DSN-less connection string of the form:

SQLDriverConnect(..."DRIVER={Easysoft ODBC-DB2};

Server=server;UID=user;PWD=password;

Database=database;"...)

where server is the host name or IP address of the machine on which the DB2 instance is running, user and password are a valid operating system user name and password and database is the DB2 database you want to connect to. You need to use the Easysoft ODBC-DB2 DRIVER keyword to identify the Easysoft ODBC-DB2 Driver.

Other Easysoft ODBC-DB2 Driver attribute settings, as described in Setting Up Data Sources on Unix, can be added to the connection string using the same PARAMETER=value; format. For example, the following connection string connects to a DB2 instance that is listening on a non-standard port:

"DRIVER={Easysoft ODBC-DB2};Server=myhost;UID=myuser;PWD=mypassword;Database=SAMPLE;Port=50001"