andreas1234567 has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

I get the following error after having upgraded DBI and DBD::DB2 to the latest versions (1.604 and 1.1, respectively):

$ /usr/bin/perl use strict; use warnings; use DBI; use DBD::DB2; DBI->connect('DBI:DB2:viper', 'db2inst3', ''); __END__ DBI connect('viper','db2inst3',...) failed: Total Environment allocation failure! Did you set up your DB2 client environment?
The intarweb suggests it has something do to with the environment variables, which are as follows:
$ set | egrep '(DB2|INSTHOME)' CUR_INSTHOME=/home/db2inst3 DB2DIR=/opt/ibm/db2/V9.5 DB2INSTANCE=db2inst3 INSTHOME=/home/db2inst3
Note that I can access the database on the command line just fine:
$ db2 connect to viper Database Connection Information Database server = DB2/LINUX 9.5.0 SQL authorization ID = DB2INST3 Local database alias = VIPER $ db2 select CURRENT_TIMESTAMP from sysibm.sysdummy1 1 -------------------------- 2008-04-24-15.00.39.518770 1 record(s) selected.
Any guidance as to how to resolve this issue is appreciated.
--
No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]

Replies are listed 'Best First'.
Re: "Total Environment allocation failure" after DBI and DBD::DB2 upgrade
by tachyon-II (Chaplain) on Apr 24, 2008 at 13:35 UTC

    Try:

    $ cd /home/db2inst3/sqllib $ . ./db2profile

    For DB2 and CGI you used to need:

    SetEnv DB2_PATH /opt/IBM/db2/V9.5 SetEnv DB2INSTANCE db2inst3 SetEnv SQLLIB /opt/IBM/db2/V9.5/sqllib
      Thanks tachyon-II. I think I already got those covered:
      $ tail -5 ~/.bashrc if [ -f /home/db2inst3/sqllib/db2profile ]; then . /home/db2inst3/sqllib/db2profile fi $ ls -l /home/db2inst3/sqllib/db2profile -rwxr-xr-x 1 db2inst3 db2iadm1 6625 Apr 24 12:26 /home/db2inst3/sqlli +b/db2profile $ /home/db2inst3/sqllib/db2profile $ perl use strict; use warnings; use DBI; use DBD::DB2; DBI->connect('DBI:DB2:viper', 'db2inst3', ''); __END__ DBI connect('viper','db2inst3',...) failed: Total Environment allocati +on failure! Did you set up your DB2 client environment? at - line 5
      Could the explanation lay elsewhere?
      --
      No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]

        The line in your .bashrc and what you type at the command line are not equivalent. There is a subtle and very important difference, particularly when it comes to setting the environment.

        $ /home/db2inst3/sqllib/db2profile

        Will fork a subshell, set the environment (for that subshell), and exit. The environment in your current shell remains unchanged.

        Although your .bashrc should be handling it there would seem to be no harm in trying either of these which will run db2profile in your current shell.

        $ . /home/db2inst3/sqllib/db2profile $ source /home/db2inst3/sqllib/db2profile