Question

I have a problem disabling validation of the connection in Apache::DBI.
From the perldoc:

Apache::DBI->setPingTimeOut($data_source, $timeout)

This configures the usage of the ping method, to validate a connection. Setting the timeout to 0 will always validate the database connection using the ping method (default). Setting the timeout < 0 will de-activate the validation of the database handle.

I tried calling setPingTimeOut with the same $data_source as in connect() but it didn't work. Did anyone manage to disable the pings?

Was it helpful?

Solution

To clarify, the code has:

# use a DSN without attribute settings specified within !
sub setPingTimeOut {
    my $class       = shift;
    my $data_source = shift;
    my $timeout     = shift;

    # sanity check
    if ($data_source =~ /dbi:\w+:.*/ and $timeout =~ /\-*\d+/) {
        $PingTimeOut{$data_source} = $timeout;
    }
}

Note the 'sanity check'. Hence ping timeout for a data source name with uppercase 'DBI:' will be silently ignored.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top