C
citybug_ch
Unregistered / Unconfirmed
GUEST, unregistred user!
constructor ThreadTracData.Create(ConnStr: String;
URL: string);
begin
uConnStr:=ConnStr;
uURL:=URL;
Conn:=TADOConnection.Create(nil);
inherited Create(False);
end;
procedure ThreadTracData.Execute;
var
strsql: string;
i: integer;
PostStr: string;
strMsg: string;
sParam: TStringStream;
begin
{ Place thread code here }
SuperviseInfaceService.idHttp.Request.ContentType :='application/x-www-form-urlencoded';
SuperviseInfaceService.IdHTTP.ReadTimeout:=5000;
//try
while not Terminateddo
begin
CoInitialize(nil);
while not Conn.Connecteddo
begin
try
Conn.ConnectionString :=uConnStr;
Conn.LoginPrompt :=False;
Conn.Connected :=True;
SuperviseInfaceService.Query.Connection :=Conn ;
SuperviseInfaceService.LogMessage('aa');
except
SuperviseInfaceService.LogMessage('bb');
end;
end;
end;
end;
开始运行时数据库正常,如果我停掉数据库后,运行中不能判断连接已经断开。恢复数据库服务后,也不能判断数据库已经恢复。
请问:如何解决这个问题?
如果数据库连接CONN是从主线程传过来的,这样又该怎么判断数据库连接是否正常呢?
URL: string);
begin
uConnStr:=ConnStr;
uURL:=URL;
Conn:=TADOConnection.Create(nil);
inherited Create(False);
end;
procedure ThreadTracData.Execute;
var
strsql: string;
i: integer;
PostStr: string;
strMsg: string;
sParam: TStringStream;
begin
{ Place thread code here }
SuperviseInfaceService.idHttp.Request.ContentType :='application/x-www-form-urlencoded';
SuperviseInfaceService.IdHTTP.ReadTimeout:=5000;
//try
while not Terminateddo
begin
CoInitialize(nil);
while not Conn.Connecteddo
begin
try
Conn.ConnectionString :=uConnStr;
Conn.LoginPrompt :=False;
Conn.Connected :=True;
SuperviseInfaceService.Query.Connection :=Conn ;
SuperviseInfaceService.LogMessage('aa');
except
SuperviseInfaceService.LogMessage('bb');
end;
end;
end;
end;
开始运行时数据库正常,如果我停掉数据库后,运行中不能判断连接已经断开。恢复数据库服务后,也不能判断数据库已经恢复。
请问:如何解决这个问题?
如果数据库连接CONN是从主线程传过来的,这样又该怎么判断数据库连接是否正常呢?