我试图在SQL Server 2008上执行存储过程。 大约30秒后,它结束了
SQLSTATE [HY000]:常规错误:20003 Adaptive Server连接定时 出[20003]
我已检查过是否允许SQL Server远程连接,并且它们的超时时间为600秒(默认值)。
这是我的config.yml
doctrine:
dbal:
default_connection: default
connections:
default: ...
mssql:
driver_class: \Lsw\DoctrinePdoDblib\Doctrine\DBAL\Driver\PDODblib\Driver
host: mssql_freetds
port: "%stage_database_port%"
dbname: "%stage_database_name%"
user: "%stage_database_user%"
password: "%stage_database_password%"
charset: UTF8
options:
timeout: 600 // I don't know if it's correct but it doesn't work even without this
这是我的代码
$connection = $this->getDoctrine()->getManager('mssql')
->getConnection();
$stmt = $connection->prepare("Exec SP_MyStoreProcedure ?, ?");
$stmt->bindValue(1, $sd->format("Y-m-d") /* This is a date */);
$stmt->bindValue(2, $ed->format("Y-m-d") /* This is a date */);
$stmt->execute();
[编辑]
所以,我发现由于LswDoctrinePdoDblib,我应该在freetds配置上配置超时。我编辑了/etc/freetds/freetds.conf文件,但它仍然在30秒后结束连接
/etc/freetds/freetds.conf
# $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $
#
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory.
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage "man freetds.conf".
# Global settings are overridden by those in a database
# server specific section
[global]
# TDS protocol version
; tds version = 4.2
# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
; dump file = /tmp/freetds.log
; debug flags = 0xffff
# Command and connection timeouts
timeout = 600
connect timeout = 600
[mssql_freetds]
host = 192.168.0.xx
port = 1433
timeout = 600
tds version = 8.0
client charset = UTF-8
text size = 20971520
[编辑2]
除此之外,没有什么能超时:
doctrine:
dbal:
default_connection: default
connections:
default: ...
mssql:
driver_class: \Lsw\DoctrinePdoDblib\Doctrine\DBAL\Driver\PDODblib\Driver
host: mssql_freetds
port: "%stage_database_port%"
dbname: "%stage_database_name%"
user: "%stage_database_user%"
password: "%stage_database_password%"
charset: UTF8
options:
2: 600 # 2 is the equivalent of \PDO::ATTR_TIMEOUT
但是商店程序应该在17秒内结束,它等待10分钟,结果相同。我不知道为什么。它似乎是一个FREETDS / SQL SERVER错误或类似的东西......
[编辑3] 发现问题是" NOT IN"存储过程的SQL中的子句。我必须用WHFT语句中的LEFT JOIN和IS NULL子句替换它。还有一个" IN"条款但它的工作原理。我不知道它是FREETDS还是LswDoctrinePdoDblib问题。