title: Perl DBD::ODBC stuck using the same ODBC Driver Manager
body: <p>I have a problem where-by I cannot get Perl DBD::ODBC to use unixODBC after re-compiling and re-installing.  It had been previously installed.</p>
  
  <p>I had compiled DBD::ODBC to use the DataDirect ODBC Driver Manager.  I now want to recompile it to use unixODBC.  However, despite starting with fresh source, configuring (it picks up unixODBC), and then compiling and installing, it seems to be stuck using the DataDirect ODBC Driver Manager.  I've gone as far as deleting all the files (I know of) from the Perl module folders, but the problem remains when it's reinstalled.</p>
  
  <p>I'm compiling from source because the server I'm installing on doesn't have an Internet connection, so I haven't been using CPAN.</p>
  
  <p>I'm using unixODBC 1.2.3 with Perl 5.8.4 (it matches the environment) on Solaris 10.</p>
  
  <p>I've removed all I can find:</p>
  
  <pre><code> 1. cd /usr/perl5/site_perl/5.8.4/sun4-solaris-64int/auto/DBD/
   2. sudo rm -R ODBC
   3. cd /usr/perl5/site_perl/5.8.4/sun4-solaris-64int/DBD/
   4. sudo rm -R ODBC
   5. sudo rm ODBC.pm
   6. cd /usr/perl5/5.8.4/man/man3/
   7. sudo rm DBD::ODBC.3
   8. sudo vi /usr/perl5/5.8.4/lib/sun4-solaris-64int/perllocal.pod
  </code></pre>
  
  <p>I then removed all entries for DBD::ODBC in <code>perllocal.pod</code>.</p>
  
  <p>I can see when I run <code>perl Makefile.PL</code> that it is finding unixODBC.</p>
  
  <pre><code>Looking for odbc_config at /usr/local/unixODBC_sp64/bin/odbc_config
    Found odbc_config (via /usr/local/unixODBC_sp64/bin/odbc_config) version 2.3.2
  
    odbc_config reports --prefix=/usr/local/unixODBC_sp64
    odbc_config reports --include-prefix=/usr/local/unixODBC_sp64/include
    odbc_config reports --lib-prefix=/usr/local/unixODBC_sp64/lib
    ODBC INC dir set to /usr/local/unixODBC_sp64/include from odbc_config
    ODBC LIB dir set to /usr/local/unixODBC_sp64/lib from odbc_config
  Using ODBC HOME /usr/local/unixODBC_sp64
  
  This looks like a unixodbc type of driver manager.
  Looking for odbcinst
    odbcinst -j reports:
  
  unixODBC 2.3.2
  DRIVERS............: /usr/local/unixODBC_sp64/etc/odbcinst.ini
  SYSTEM DATA SOURCES: /usr/local/unixODBC_sp64/etc/odbc.ini
  FILE DATA SOURCES..: /usr/local/unixODBC_sp64/etc/ODBCDataSources
  USER DATA SOURCES..: /usr/local/unixODBC_sp64/etc/odbc.ini
  </code></pre>
  
  <p>Here are all environment variables relating to ODBC in the environment on which I'm compiling and installing the module</p>
  
  <pre><code>LD_LIBRARY_PATH=/usr/local/unixODBC_sp64/lib:
  LD_LIBRARY_PATH_64=/usr/local/unixODBC_sp64/lib:
  PATH=/usr/local/unixODBC_sp64/bin:/usr/sfw/bin:/usr/ccs/bin:/opt/SUNWspro/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/bin
  ODBCINI=/usr/local/unixODBC_sp64/etc/odbc.ini
  ODBCHOME=/usr/local/unixODBC_sp64
  </code></pre>
  
  <p>When I run a test I still see an error from the DataDirect driver manager:</p>
  
  <pre><code>DBI connect('lksdjhf','ljkshdf',...) failed: [DataDirect][ODBC lib] System information file not found. Please check the ODBCINI environment variable. (SQL-IM002) at ./test_odbcdb2.pl line 19
  </code></pre>
  
  <p>Ignore the fact that it can't find the driver, because odbc.ini isn't populated.  I'm testing with a junk connection because I want to see this same error message from unixODBC.</p>
  
  <p>The Perl script I'm using for testing is below.  It works with the DataDirect driver manager.</p>
  
  <pre><code>#!/usr/bin/perl -w
  
  use DBI;
  use DBD::ODBC;
  use DBD::DB2::Constants;
  
  print "Enter Data Source Name:";
  my $dsn =&lt;STDIN&gt;;
  chomp $dsn;
  my $data_source = "DBI:ODBC:$dsn";
  print "Enter Username:";
  my $user =&lt;STDIN&gt;;
  print "Enter password:";
  my $password =&lt;STDIN&gt;;
  chomp $user;
  chomp $password;
  
  # Connect to the db2 database using odbc
  my $dbh = DBI-&gt;connect($data_source, $user, $password, {AutoCommit =&gt;1})
                  or die "Can't connect to $data_source: $DBI::errstr";
  $stmt = "SELECT current timestamp from sysibm.sysdummy1; ";
  $sth = $dbh-&gt;prepare($stmt);
  $sth-&gt;execute();
  
  #associate variable with output columns...
  
  $sth-&gt;bind_col(1,\$timestap);
  while ($sth-&gt;fetch) {
             print "The time is: $timestap\n";
  }
  $dbh-&gt;disconnect;
  </code></pre>