So you are not using any kind of ping at all now? And this works? If you just want to turn off ping completely, I think Apache::DBI has an option for this. But was not your problem that the connection broke and you wanted automatic reconnects? Your code does not seem to do that.
sub DESTROY { my $self=shift; if ($dbhobject) { $dbhobject = undef; } }
I doubt that this DESTROY method is called ever. Your $dbhobject is not a blessed reference (just a plain hash ref containing the DBI handle), so this is not really OOP and $classname, $self and so on are a little confusing.

Update: Okay, maybe I misunderstood. This is the old code you were using (with Apache::DBI)? And it did not reconnect? If so, you were not using Apache::DBI correctly. You have to use "connect" to get a connection, and Apache::DBI will either make a really new connection or just return an alreay open connection. That is transparent to you. What you cannot do is cache the connection Apache::DBI give you in your own singleton object. You have to "connect" every time you want a connection: So instead of

sub new { my $classname = shift; my $self={}; if ($dbhobject) { $self=$dbhobject } else { $self = bless {}; my $dbh = DBI->connect("DBI:mysql:blah) or die DBI::errstr; $self->{"dbh"} = $dbh; } $self; } sub DBHOBJ { return $dbhobject->{"dbh"}; }
use
use Apache::DBI; sub DBHOBJ { DBI->connect("DBI:mysql:blah) or die DBI::errstr; }

In reply to Re^3: Singletons, Apache::DBI and MySQL by Thilosophy
in thread Singletons, Apache::DBI and MySQL by jbrugger

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.