3

我在禁用Apache::DBI.
perldoc

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

这配置了 ping 方法的使用,以验证连接。将超时设置为 0 将始终使用 ping 方法(默认)验证数据库连接。设置超时 < 0 将停用数据库句柄的验证。

我尝试setPingTimeOut使用与中相同的 $data_source 进行调用,connect()但没有成功。有没有人设法禁用ping?

4

1 回答 1

4

为了澄清,代码有:

# 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;
    }
}

请注意“健全性检查”。因此,带有大写“DBI:”的数据源名称的 ping 超时将被静默忽略。

于 2010-12-16T15:07:05.420 回答