Can't connect to MySQL if open/close TZConnection in loop.
Posted: 26.01.2008, 05:23
I used Zeoslib 6.6.0-beta with Delphi 7 to write some business logics on server side that must create TZConnection on the fly per client call.But if calling is in loop for a long time, I got error 'Can't connect to MySQL server on 127.0.0.1 (10048)' and MySQL stop working for about 1 minute. I try to simulate the following code which make equivalent situation and the same error. Can anyone help? I used MySQL 5.0.45 and its default settings.
for i:=0 to 6000 do {more likely error for more loop count}
begin
Con := TZConnection.Create(nil);
Q := TZQuery.Create(nil);
try
Con.Database := 'myDB';
Con.User := 'root';
Con.Password := 'mypassword';
Con.HostName := '127.0.0.1';
Con.Protocol := 'mysql-5';
Q.Connection := Con;
Q.Close;
Q.SQL.Text := 'select item_id from items';
Q.Open;
finally
Q.Free;
Con.Free;
end;
end;
Jaras
for i:=0 to 6000 do {more likely error for more loop count}
begin
Con := TZConnection.Create(nil);
Q := TZQuery.Create(nil);
try
Con.Database := 'myDB';
Con.User := 'root';
Con.Password := 'mypassword';
Con.HostName := '127.0.0.1';
Con.Protocol := 'mysql-5';
Q.Connection := Con;
Q.Close;
Q.SQL.Text := 'select item_id from items';
Q.Open;
finally
Q.Free;
Con.Free;
end;
end;
Jaras