Dear Monks,

I've this program that once in a while runs for weeks. But, after running for a few days, somehow the connection with the database gets lost. I searched the form and found mysql_auto_reconnect, which seems to work. I've tested it by doing
$mysql->disconnect() ; $sth = $mysql->prepare(...) ; ......
So, how can I tell now if I'm disconnected ?
But, I don't really like this solution, because this only works if you have $mysql->{autocommit} = 1
So what I tried was:
$sth = $mysql->prepare(...) ; if ( ! $sth-execute() ) { # connection lost ? # reconnect }
So I assumed that if a request failed, the connection was lost. Anyway, to simulate a lost connection I added before the prepare() a
But now, my perl script stops when it tries to execute the sql command ?

Any suggestions ?

Thanks a lot in advance

In reply to mysql_auto_reconnect by Anonymous Monk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":