Chapter 4. Deploying applications with DB2 203
If there is any incorrect information, the connection will fail and suitable error
message will be thrown as shown in Example 4-43.
Example 4-43 Failed connection using itso_perlapp.pl
itsouser@ubuntu:~/redbook$ perl itso_perlapp.pl mensa 50001 test db2inst1
wrongpassword
Trying to establish connection...
Database connection not made: [IBM][CLI Driver] SQL30082N Security processing
failed with reason "24" ("USERNAME AND/OR PASSWORD INVALID"). SQLSTATE=08001
4.7.4 Deploying a Perl application with the DB2 drivers
In this section, we demonstrate how to deploy a DB2 Perl application with the
DB2 drivers. We assume that the target system has already has Perl installed,
but the DB2 drivers for Perl are not in place yet. The general tasks for deploying
a Perl application with ODBC CLI driver are as follows:
򐂰Prepare the Perl driver and the redistributable DB2 driver files.
򐂰Prepare the Perl application package.
򐂰Prepare the deployment package.
򐂰Deploying the deployment package to the target system.
We organize all the deployment files under a directory perl_deploy.

Preparing Perl driver and redistributable DB2 driver files

You can obtain the DBI and the driver file as described in “Installation of IBM Perl
driver” on page 200. The driver deployment procedure differs on Linux, UNIX and
Windows systems. For Windows, you can use IBM Data Server Driver for ODBC,
CLI (and .NET). You require IBM Data Server Client for Linux and UNIX for
building DBD::DB2.
In our example, we have downloaded the DBI and DBD::DB2 from the Internet
for Linux named as DBI-1.605.tar.gz and DBD-DB2-1.1.tar.gz respectively. We
have assumed that Perl is installed on the deployment machine and the user has
sufficient read and write permissions to install DBI and DBD::DB2. Our target
deployment machine also has IBM Data Server Client installed. We place the
DBI and driver file under perl_deploy/driver.
If you are on a Windows system, you can copy and redistribute some of the IBM
Data Server Driver for ODBC and CLI files. We discuss how to prepare the
redistributable driver files in “Preparing the redistributable driver files” on
page 159. The procedure also can be applied for preparing the DB2 drivers for
Perl to be deployed along with the application. The script requires a slight
modification.