This example illustrates how to connect to an IBM DB2 database through ODBC.
•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.
To connect to IBM DB2:
1.Start the database connection wizard and select IBM DB2 (ODBC/JDBC).
3.Select ODBC, and click Next. If prompted to edit the list of known drivers for the database, select the database drivers applicable to IBM DB2 (see Prerequisites), and click Next.
4.Select the IBM DB2 driver 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 this example, DB2DSN), and then click Add.
6.On the Data Source tab, enter the user name and password to 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 again the username and password, and then click OK.