Connect to IBM DB2 Server (FireDAC)

From Appmethod Topics
Jump to: navigation, search

Go Up to Database Connectivity (FireDAC)

This topic describes how to connect to IBM DB2 Server.

Supported Versions

The FireDAC native driver supports IBM DB2 Enterprise, Workgroup, or Express editions version 8 and later. We recommend v 8.2 at least. You can also work with other IBM database products using FireDAC ODBC or DBX Bridge drivers.

Windows Client Software

FireDAC 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. These can be downloaded from the following locations:

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

If the DB2 ODBC driver has not been installed properly, an exception is raised when you try to connect:

[FireDAC][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 (see Defining Connection (FireDAC) for details).

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. Note that the passwords with both '{' and '}' are not supported. master
LoginTimeout Controls the amount of time, in seconds, before an application times out while attempting 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
ExtendedMetadata

Controls the extended description of the query result sets:

  • True -- FireDAC describes a result set to obtain all the possible column attributes - is read-only, is auto incrementing, column origin, and so on. Setting this option to True slightly slows down a dataset opening.
  • False -- FireDAC uses the restricted information about the query columns (default).
True
ODBCAdvanced Allows you to specify any other additional ODBC connection parameter value. The default value is "IGNOREWARNINGS=1".
MetaDefSchema Default schema name. The design time code excludes the schema name from the object name if it is equal to MetaDefSchema. db2admin

Use Cases

  • Connect to DB2 using the 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

See Also