線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:3768
推到 Plurk!
推到 Facebook!

ConnectionTimeout与CommandTimeout的区别

答題得分者是:azurecloud
luowy651
高階會員


發表:257
回覆:313
積分:114
註冊:2003-04-09

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-02-23 14:26:42 IP:218.72.xxx.xxx 未訂閱
各位大大: 我想请教一下,我在使用ADOConnection1时,发现有两个timeout,一个是 ADOConnection1.CommandTimeout,另一个是ADOConnection1.ConnectionTimeout,请问两者在使用时有何区别?在出现"timeout"问题时该如何分别设置这两项,越大越好吗? 谢谢!
azurecloud
中階會員


發表:52
回覆:108
積分:92
註冊:2003-09-04

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-02-23 22:58:09 IP:163.13.xxx.xxx 未訂閱
Hi,luowy651 您好:     ConnectionTimeout 是指在「連接」時,預定終止的時間,例如說下 ADOConnection1.open; 然後過了15秒(預設 ConnectionTimeout為15秒)程式沒 收到資料庫系統的回應的話,就會回應一個例外(Exception)。     而 CommandTimeout 則是指 「執行」某些動作的預定終止時間,例如說下 ADOConnection1.Execute(...)時,尤其是當處理的資料量愈大時,處理時間會 愈久,若是在 CommandTimeout(預設 30秒)之前還沒做完,沒傳回成功的回應訊 息的話,也會產生一個例外(Exception)。     個人是覺得 ConnectionTimeout 的時間不必特意去設定,但 CommandTimeout 若是你需要處理大量資料時不妨設大一點較好。      像這樣的問題建議您先查詢 Delphi 本身的 help 檔案,搜尋 TADOConnection 就可看其子項目的說明,以下貼出 Help 檔原文。    Specifies amount of time to attempt a connection.    property ConnectionTimeout: Integer;    Description    Use ConnectionTimeout to specify the amount of time, in seconds, that can expire before an attempt to make a connection is considered unsuccessful. The default value is 15 seconds.    If a connection is successfully made prior to the expiration of the seconds specified or the Cancel method is called, ConnectionTimeout has no effect. If the specified time expires and a connection has not been successfully made, the attempt is terminated and an exception is raised.    ********************************************************************** Specifies amount of time to attempt execution of a command.    property CommandTimeout: Integer;    Description    Use CommandTimeout to specify the amount of time, in seconds, that that can expire before an attempt to execute a command is considered unsuccessful. The default value is 30 seconds.    If a command successfully executed prior to the expiration of the seconds specified in CommandTimeout, this property has no effect. If execution of a command has not been successfully completed before the time has elapsed, the command is canceled.    希望幫的上忙。    =========== 努力修行中... ===========
azurecloud
中階會員


發表:52
回覆:108
積分:92
註冊:2003-09-04

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-02-23 23:02:30 IP:163.13.xxx.xxx 未訂閱
對不起,容我更正,原文是說會 取消(canceled) 這個 command。 ADOConnection1.Execute(...)時,尤其是當處理的資料量愈大時,處理時間會 愈久,若是在 CommandTimeout(預設 30秒)之前還沒做完,沒傳回成功的回應訊 息的話,也會產生一個例外(Exception)。這裡寫錯了,抱歉 =========== 努力修行中... ===========
luowy651
高階會員


發表:257
回覆:313
積分:114
註冊:2003-04-09

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-02-23 23:09:20 IP:61.164.xxx.xxx 未訂閱
谢谢azurecloud大大!!
luowy651
高階會員


發表:257
回覆:313
積分:114
註冊:2003-04-09

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-02-23 23:14:22 IP:61.164.xxx.xxx 未訂閱
谢谢azurecloud大大!! 还能再问一下,我在adoconnection中使用connectionstring设置sql连接时,还有一个general timeout不知是何意思?
azurecloud
中階會員


發表:52
回覆:108
積分:92
註冊:2003-09-04

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-02-23 23:42:40 IP:163.13.xxx.xxx 未訂閱
Hi,luowy651 您好:     我想您說的應該是在設定 ADOConnection 元件的 connectionstring屬性 時,用自行 build 連接字串時,如下圖的 general timeout 吧? 對不起,小弟也查不到這個屬性的資料,我猜想它是屬於 windows api 的屬 性而不是 Delphi 的,或許你可以用上面這張圖另外提問,讓其他先進為您解答。網址如下 http://delphi.ktop.com.tw/loadfile.php?TOPICID=14207709&CC=317751 我個人的感覺是 connection timeout 不必特別去更改設定(也從沒改過general timeout), 若是預設的時間內連不上,通常都是資料庫所在的 server 出了什麼問題,除 非您的資料庫是放在網際網路上,無法控制網路連接的時間那才另當別論,給您參考。 =========== 努力修行中... ===========
系統時間:2024-06-29 16:08:44
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!