Hello all.
This seems like it should be a simple problem, and I get the feeling I'm missing something obvious.
Preamble: I'm running ActiveState's Perl v5.8.7 on Windows XP. I have DBD::Mysql v3.0002 and DBI v1.48, installed via PPM. My MySql server is v3.23.54, running on Redhat Linux.
My understanding of mysql_auto_reconnect from the DBD::Mysql docs is that it should automatically reconnect if the server has timed out a connection.
However, in this simple test case:
use strict; use DBI; my $mysql = DBI->connect('DBI:mysql:database=mydb;host=myhost;port=330 +6', 'user', 'password', {RaiseError => 1}); $mysql->{mysql_auto_reconnect} = 1; while (1) { my $query = $mysql->prepare("select count(*) from sometable"); $query->execute(); my ($count) = $query->fetchrow_array; printf "Found %d records.\n", $count; sleep 5*60; # In reality, my program does lots of other things her +e that may take a while. }
It works correctly the first time, but the second time through the loop, I get:
DBD::mysql::st execute failed: Lost connection to MySQL server during +query at foo.pl line 11. DBD::mysql::st execute failed: Lost connection to MySQL server during +query at foo.pl line 11.
(Yes, I did say that twice. (Echo. Echo. :-)))
The server is set to time out after 4 minutes, but why isn't the client auto-reconnecting as necessary?
Am I calling mysql_auto_reconnect in the wrong way? Am I misunderstanding what it's meant to do? Any thoughts will be greatly appreciated.
Many thanks,
Neil.
Edit: g0n - replaced pre tags with code tags
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |