Skip to content
Snippets Groups Projects
Commit 843eec00 authored by Graham McVicker's avatar Graham McVicker
Browse files

DBConnection::disconnect_if_idle now uses $dbh->{Kids} instead of...

DBConnection::disconnect_if_idle now uses $dbh->{Kids} instead of $dbh->{ActiveKids} to prevent problems with multiple prepared statement handles
parent c14e1a2a
No related branches found
No related tags found
No related merge requests found
...@@ -179,12 +179,14 @@ sub connect { ...@@ -179,12 +179,14 @@ sub connect {
$dbh = DBI->connect($dsn, $dbh = DBI->connect($dsn,
$self->username(), $self->username(),
$self->password(), $self->password(),
{RaiseError => 1}); {'RaiseError' => 1});
}; };
$dbh || throw("Could not connect to database " . $self->dbname() . if(!$dbh || $@) {
" as user " . $self->username() . throw("Could not connect to database " . $self->dbname() .
" using [$dsn] as a locator:\n" . $DBI::errstr); " as user " . $self->username() .
" using [$dsn] as a locator:\n" . $DBI::errstr);
}
$self->db_handle($dbh); $self->db_handle($dbh);
...@@ -446,7 +448,6 @@ sub prepare { ...@@ -446,7 +448,6 @@ sub prepare {
# return an overridden statement handle that provides us with # return an overridden statement handle that provides us with
# the means to disconnect inactive statement handles automatically # the means to disconnect inactive statement handles automatically
bless $sth, "Bio::EnsEMBL::DBSQL::StatementHandle"; bless $sth, "Bio::EnsEMBL::DBSQL::StatementHandle";
$sth->dbc($self); $sth->dbc($self);
return $sth; return $sth;
...@@ -516,7 +517,7 @@ sub do { ...@@ -516,7 +517,7 @@ sub do {
sub disconnect_if_idle { sub disconnect_if_idle {
my $self = shift; my $self = shift;
if(!$self->db_handle()->{'ActiveKids'} && if(!$self->db_handle()->{'Kids'} &&
!$self->db_handle()->{'InactiveDestroy'}) { !$self->db_handle()->{'InactiveDestroy'}) {
$self->db_handle->disconnect(); $self->db_handle->disconnect();
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment