Open anhuizf1 opened 6 years ago
Please put your code to reproduce here.
I have a very slow SQL that I'm calling, that puts a lot of data together. I'd like to set the Command Timeout to 1800 seconds, but I don't know how to write code.
var conf []string var db *sql.DB var err error conf = append(conf, "Provider=SQLOLEDB") conf = append(conf, "Data Source=(local)") // sqlserver IP 和 服务器名称 conf = append(conf, "Initial Catalog=master") // 数据库名 conf = append(conf, "user id=sa") // 登陆用户名 conf = append(conf, "password=Howlink@1401") // 登陆密码 conf = append(conf, "keepAlive=0") conf = append(conf, "connection timeout=0") fmt.Println(strings.Join(conf, ";")) db, err = sql.Open("adodb", strings.Join(conf, ";")) if err != nil { fmt.Println("sql open:", err) return } // 执行SQL语句 fmt.Println("start") fmt.Println(time.Now()) fmt.Println("=====1=====") fmt.Println(time.Now())
res, err := db.Query("WAITFOR DELAY '00:02'")
if err != nil {
fmt.Println(err)
fmt.Println(time.Now())
return
}
fmt.Println(res)
How to set timeout
rv, err = oleutil.PutProperty(s, "CommandTimeout", 1800) if err != nil { return nil, err }
1800 as parameter from outer