admin管理员组

文章数量:1335122

I have a problem with a function that interacts with the database. When I call it sequentially, it works perfectly, but when I call it concurrently, it gives me an error.

Is ZeosLib not thread-safe, and how can I fix this issue? I don't want to create a new connection each time I call the function, as I'm using a single connection for all requests.

I'm using Firebird, Delphi 12, and ZeosLib 6.5.1 (alpha).

Here is the function I am using:

procedure TestFunction;
var
Query: TZEOSQuery;
begin
Query := TZEOSQuery.Create(nil);
try
Query.Connection := MyConn;

MyConn.StartTransaction;

Query.SQL.Text := 'SELECT * FROM project';
Query.Open;

while not Query.EOF do
begin
Query.Next;
end;

MyConn.Commit;
finally
Query.Close;
Query.Free;
end;
end;

本文标签: multithreadingIssue with concurrent database calls Using ZeosLibStack Overflow