AnyDAC
ContentsIndexHome
PreviousUpNext
Connect to IBM DB2 Server

Describes how to connect to IBM DB2 Server.

Group
Links
Supported versions

The AnyDAC native driver supports IBM DB2 Enterprise, Workgroup or Express editions version 8 and higher. We recommend v 8.2 at least. 

You can also work with other IBM database products, using AnyDAC/ODBC or DBX Bridge drivers. 

 

Windows client software

AnyDAC requires the "IBM DATA SERVER DRIVER for ODBC", "IBM DB2 ODBC DRIVER" or "IBM DB2 DRIVER FOR ODBC" x86 or x64 ODBC driver to be installed on the workstation. It may be downloaded from:

After downloading and unpacking run "<client>\bin\db2oreg1 -i" to install ODBC driver. Additionally, download and install fix packs. 

When the DB2 ODBC driver has not been properly installed, you will get an exception when you try to connect: 

 

[AnyDAC][Phys][ODBC][Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

 

Driver linkage

To link the driver:

 

Connection definition parameters

There are two methods of specifying the DB2 connection attributes. If the DB2 client software has the DB2 connection aliases configured, an application should use the Alias parameter. If no aliases are configured, then you should use the Protocol, Server, Port and Database parameters. Also specify User_Name and Password

 

DriverID=DB2  

Parameter 
Description 
Example value 
Alias 
Connection alias. 
MyDB2Srv 
Server 
Host name, if Alias is not specified. 
127.0.0.1 
Port 
Port value, if Alias is not specified. 
5000 
Database 
Database name, if Alias is not specified. 
ADDEMO 
Protocol 
Protocol name, if Alias is not specified. 
TCPIP 
User_Name 
The DB2 user name. 
db2admin 
Password 
The DB user password. 
master 
LoginTimeout 
Controls the amount of time in seconds an application waits for a connection attempt to timeout while waiting to establish a connection (0 specifies an infinite wait). 
30 
StringFormat 
Defines how to represent String values:
  • Choose - represent as ftString / ftWideString / ftMemo / ftWideMemo, depending on the declared data type name (default);
  • Unicode - always represent as ftWideString / ftWideMemo.
 
Unicode 
ODBCAdvanced 
Allows to specify any other additional ODBC connection parameter value. The default value is "IGNOREWARNINGS=1". 
 
MetaDefSchema 
Default schema name. Design time code will exclude schema name from object name, if it is equal to MetaDefSchema. 
db2admin 

 

Usage cases
  • Connect to DB2 using existing database alias:

 

DriverID=DB2
Alias=addemo
User_Name=db2admin
Password=mypwd
MetaDefSchema=db2admin

 

  • Connect to DB using full connection information:

 

DriverID=DB2
Server=127.0.0.1
Database=addemo
Port=50000
Protocol=TCPIP
User_Name=db2admin
Password=mypwd
MetaDefSchema=db2admin
What do you think about this topic? Send feedback!