multithreading - Issue with concurrent database calls Using ZeosLib - Stack Overflow

I have a problem with a function that interacts with the database. When I call it sequentially, it work

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;

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742349742a4427272.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信