[CDBI] Lost connection to MySQL server during query

Carlos Vicente cvicente at network-services.uoregon.edu
Fri Jan 20 20:52:19 GMT 2006


On Fri, 2006-01-20 at 11:11 -0800, John Beppu wrote:
> Here's one that hit me very recently.
> 
> http://dev.mysql.com/doc/refman/5.0/en/gone-away.html#c7112
> 

Hmm... I don't know if that applies to my case.  You say that you
"absentmindedly set AutoCommit to 0".  Does that mean you "explicitly"
set it to 0 or that you just didn't supply the parameter?  

This is what I have (mostly borrowed from the Wiki):

Netdot::DBI->connection('dbi:mysql:netdot', 'user', 'pass');

# Get Class::DBI's default dbh options
my $db_options = { __PACKAGE__->_default_attributes };

__PACKAGE__->_remember_handle('Main'); # so dbi_commit works

# override default to avoid using Ima::DBI closure
sub db_Main {
    my $dbh;
    if ( $ENV{'MOD_PERL'} and !$Apache::ServerStarting ) {
        $dbh = Apache->request()->pnotes('dbh');
    }
    if ( !$dbh ) {
        $dbh = DBI->connect_cached('dbi:mysql:netdot', 'user', 'pass',
$dboptions);
        if ( $ENV{'MOD_PERL'} and !$Apache::ServerStarting ) {
            Apache->request()->pnotes( 'dbh', $dbh );
        }
    }
    return $dbh;
}

As you see, I'm not passing the parameter.  CDBI docs claim that
AutoCommit=>1 is the default (unless you're using Pg or Oracle).


cv




More information about the ClassDBI mailing list