Connecting to IBM DB2 (ODBC)
This example illustrates how to connect to an IBM DB2 database via ODBC.
Prerequisites
•IBM Data Server Client must be installed and configured on your operating system (this example uses IBM Data Server Client 9.7). For installation instructions, check the documentation supplied with your IBM DB2 software. After installing the IBM Data Server Client, check if the ODBC drivers are available on your machine (see Viewing the Available ODBC Drivers).
•Create a database alias. There are several ways to do this:
oFrom IBM DB2 Configuration Assistant
oFrom IBM DB2 Command Line Processor
oFrom the ODBC data source wizard (for this case, the instructions are shown below)
•You have the following database connection details: host, database, port, username, and password.
Connection
1.Start the database connection wizard, select Connection Wizard and then IBM DB2 (ODBC/JDBC). Click Next.
2.Select ODBC and click Next.
3.If prompted to edit the list of known drivers for the database, select the database drivers applicable to IBM DB2 (see Prerequisites above) and click Next.
4.Select the IBM DB2 driver you want from the list, and then click Connect. (To edit the list of available drivers, click Edit Drivers, and then check or uncheck the IBM DB2 drivers you wish to add or remove, respectively.)
5.Enter a data source name (in the screenshot below, DB2DSN), and then click Add.

6.On the Data Source tab, enter the user name and password for the database.
7.On the TCP/IP tab, enter the database name, a name for the alias, the host name, and the port number, and then click OK.
8.Enter the username and password again, and then click OK.