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"; } }
In reply to using DESTROY to DBI disconnect by WAP_happens
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |