I suddenly lost the ability to connect to my ODBC database yesterday, after
years of using the same function to establish a connection:

sub dbaseconnect {
    if (defined($testing)) {
        if ($testing eq "YES") {
            $dsn =  'dbi:ODBC:test1' ;
            print "Using test database\n" ;
        } elsif ($testing eq "TRAIN") {
            $dsn =  'dbi:ODBC:train1' ;
            print "Using train1 database\n" ;
        } else {
            $dsn =  'dbi:ODBC:prod1' ;
        }
    } else {
        $dsn =  'dbi:ODBC:prod1' ;
    }
    $user =  'USER' ;
    $passwd =  'PASSWORD' ;
    my %adrivers = DBI->available_drivers();
    print join(", ", %adrivers), "\n" ;

    print "connecting to DATABASE $dsn  $user $passwd\n" ;
    $dbh = DBI->connect($dsn, $user, $passwd,
                {RaiseError => 1, AutoCommit => 0})
        or die "Could not connect to database: " . DBI->errstr ;
    print "connected to DATABASE $dsn \n" ;
}

So, to gather information about where the failure is, I ran the following
program:

#! /usr/bin/perl

use DBI ;
use DBD::ODBC ;
use strict ;
use warnings ;

print "Available Drivers: " ;
my @adrivers = DBI->available_drivers();
print join(", ", @adrivers), "\n" ;

print "Data Sources: " ;
foreach my $driver ( @adrivers ) {
    print "Driver: $driver\n";
    my @dataSources = DBI->data_sources( $driver );
    foreach my $dataSource ( @dataSources ) {
        print "\tData Source is $dataSource\n";
    }
    print "\n";
}

and the output I got was:

Available Drivers: DBM, ExampleP, File, ODBC, Proxy, Sponge
Installed Drivers:
Data Sources: Driver: DBM
        Data Source is DBI:DBM:f_dir=.
        Data Source is DBI:DBM:f_dir=CIGNA
        Data Source is DBI:DBM:f_dir=Logs
        Data Source is DBI:DBM:f_dir=ONCOURSE
        Data Source is DBI:DBM:f_dir=autemp
        Data Source is DBI:DBM:f_dir=config
        Data Source is DBI:DBM:f_dir=fh.cob
        Data Source is DBI:DBM:f_dir=perlscripts
        Data Source is DBI:DBM:f_dir=pndspndwk
        Data Source is DBI:DBM:f_dir=prgrun_dir
        Data Source is DBI:DBM:f_dir=scripts

Driver: ExampleP
        Data Source is dbi:ExampleP:dir=.

Driver: File
        Data Source is DBI:File:f_dir=.
        Data Source is DBI:File:f_dir=CIGNA
        Data Source is DBI:File:f_dir=Logs
        Data Source is DBI:File:f_dir=ONCOURSE
        Data Source is DBI:File:f_dir=autemp
        Data Source is DBI:File:f_dir=config
        Data Source is DBI:File:f_dir=fh.cob
        Data Source is DBI:File:f_dir=perlscripts
        Data Source is DBI:File:f_dir=pndspndwk
        Data Source is DBI:File:f_dir=prgrun_dir
        Data Source is DBI:File:f_dir=scripts

Driver: ODBC

and the program just hangs when it looks for data sources using the ODBC
driver. So, I suspect that there are issues with the ODBC driver. Here are
the versions of the various DBI module components:

 perl -MDBI -e 'DBI->installed_versions'
  Perl            : 5.008008    (PA-RISC1.1-thread-multi)
  OS              : hpux        (11.00)
  DBI             : 1.50
  DBD::Sponge     : 11.10
  DBD::Proxy      : install_driver(Proxy) failed: Can't locate
RPC/PlClient.pm in @INC
  DBD::ODBC       : 1.14
  DBD::File       : 0.33
  DBD::ExampleP   : 11.12
  DBD::DBM        : 0.03

I imagine that I may not have the latest versions of everything, and
updates are probably in order, but, while updates are desirable, I'd like
to be sure that I'm addressing the root cause of the problem, so I get it
resolved. This issue affects a lot of programs, and is critical to our
business.
Any help or suggestions will be greatly appreciated.

Reply via email to