WAP_happens has asked for the wisdom of the Perl Monks concerning the following question:
DB disconnect failed: $DBI::err=, $DBI::errstr= during global destruction.
Can't read $DBI::err, last handle unknown or destroyed during global destruction.
Can't read $DBI::errstr, last handle unknown or destroyed during global destruction.
I could just change it back, it was working fine before, but I'm curious as to why this fails while the handle still seems to exist. Anyone know? The relevant bits (I hope) are below:
sub new() { my $class = shift; my $self = {}; $self->{'database'} = "dbi:Sybase:database=$config{'DB_NAME'};serv +er=$config{'DB_SERVER'};hostname=$config{'DB_HOST'};port=$config{'DB_ +PORT'}"; $self->{'username'} = $config{'DB_USERNAME'}; $self->{'password'} = $config{'DB_PASSWORD'}; bless ( $self , $class ); $self->{'dbh'} = $self->connect(); return $self; } sub DESTROY { my $self = shift; if ( $self->{'dbh'} ) { $self->close(); } } sub connect() { my $self = shift; my $dbh = DBI->connect( $self->{'database'}, $self->{'username'}, +$self->{'password'} ); if ( !defined( $dbh ) ) { ... } else { return $dbh; } } sub close() { my $self = shift; my $dbh = shift || $self->{'dbh'}; unless ( $dbh->disconnect() ) { warn "DB disconnect failed: \$DBI::err=$DBI::err, \$DBI::errst +r=$DBI::errstr"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 1: using DESTROY to DBI disconnect
by tilly (Archbishop) on Aug 22, 2001 at 07:46 UTC | |
|
Re: using DESTROY to DBI disconnect
by Cine (Friar) on Aug 21, 2001 at 22:36 UTC | |
|
Re: using DESTROY to DBI disconnect
by chromatic (Archbishop) on Aug 22, 2001 at 07:15 UTC | |
by htoug (Deacon) on Aug 22, 2001 at 15:09 UTC |