Monks,
I have inherited some SQL and would like some input.
I am processing some cable modem stats. Client machine is Windows Server 2008 R2, ActivePerl 5.8, using the ODBC Data Source Administrator control panel.
Script runs fine, but occasionally it exits with the following:
DBD::ODBC::st execute failed: [MySQL][ODBC 5.1 Driver][mysqld-5.1.45-community-log]Lost connection to MySQL server during query (SQL-08S01) at load_modem.wpl line 255.
Please note: I respect the Monastery's preference for actual code, but in interest of inappropriate disclosure, I have modified the following slightly. The logic has not been altered.
use strict; use warnings; use DBI; my $dbh = DBI->connect("dbi:ODBC:MySQL_for_modem"); $dbh->{LongReadLen} = 512 * 1024; $dbh->{LongTruncOk} = 1; my $sql_region_id = "select distinct region_id from config.object "; my $sql_statement = "select info from database"; unless ( $region_cursor = $dbh->prepare( "$sql_region_id" )){ exit 1; } unless ( $region_cursor->execute ) { exit 2; } $region_cursor->bind_columns(\($region_id)); while( $region_cursor->fetch() ){ unless ( $cursor = $dbh->prepare( "$sql_statement" )) { exit 1; } unless ( $cursor->execute($region_id) ) { # <-- line 255 in the sc +ript exit 2; } $cursor->bind_columns(\( $modem_ip, etc... )); while( $cursor->fetch() ) { process the stats... } }
Given that I have no control over the server that I am querying, what is the best way to have the script carry on? ie: instead of the exits (or dies if I replace them), what is a clean way to reconnect and and continue?
As always, thanks for any help and references...
Scott...
In reply to Lost connection to MySQL server by spstansbury
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |