From 843eec00dbe3f90c7199a320f04015b3812e86d6 Mon Sep 17 00:00:00 2001
From: Graham McVicker <mcvicker@sanger.ac.uk>
Date: Thu, 25 Mar 2004 14:59:40 +0000
Subject: [PATCH] DBConnection::disconnect_if_idle now uses $dbh->{Kids}
 instead of $dbh->{ActiveKids} to prevent problems with multiple prepared
 statement handles

---
 modules/Bio/EnsEMBL/DBSQL/DBConnection.pm | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/modules/Bio/EnsEMBL/DBSQL/DBConnection.pm b/modules/Bio/EnsEMBL/DBSQL/DBConnection.pm
index f22eed3df6..f752fba9a9 100644
--- a/modules/Bio/EnsEMBL/DBSQL/DBConnection.pm
+++ b/modules/Bio/EnsEMBL/DBSQL/DBConnection.pm
@@ -179,12 +179,14 @@ sub connect {
     $dbh = DBI->connect($dsn,
                         $self->username(),
                         $self->password(),
-                        {RaiseError => 1});
+                        {'RaiseError' => 1});
   };
 
-  $dbh || throw("Could not connect to database " . $self->dbname() .
-                " as user " . $self->username() .
-                " using [$dsn] as a locator:\n" . $DBI::errstr);
+  if(!$dbh || $@) {
+    throw("Could not connect to database " . $self->dbname() .
+          " as user " . $self->username() .
+          " using [$dsn] as a locator:\n" . $DBI::errstr);
+  }
 
   $self->db_handle($dbh);
 
@@ -446,7 +448,6 @@ sub prepare {
    # return an overridden statement handle that provides us with
    # the means to disconnect inactive statement handles automatically
    bless $sth, "Bio::EnsEMBL::DBSQL::StatementHandle";
-
    $sth->dbc($self);
 
    return $sth;
@@ -516,7 +517,7 @@ sub do {
 sub disconnect_if_idle {
   my $self = shift;
 
-  if(!$self->db_handle()->{'ActiveKids'} &&
+  if(!$self->db_handle()->{'Kids'} &&
      !$self->db_handle()->{'InactiveDestroy'}) {
     $self->db_handle->disconnect();
   }
-- 
GitLab