Subject Re: [ib-support] Re: Can anyone help: Error reading data from the connection
Author Martijn Tonies
> I have the same question as Martijn? Why can't threads share a db
> handle / connection? As long as they are not concurrently sharing
> the connection why can't this work?
> Prior to this problem, I started a connection each time a thread was
> created however this approach was too expensive, in terms of time.
> Each call into isc_attach_database() is around 1.5 seconds. Can I do
> anything about this?

Despite all this - it seems you need a different approach.

Think of a pool of workerthreads that each have their own db-connection.

When you need something done, pass a "job" to them and call the .Execute
method (or whatever language you're usign) - for example:

TWorkerThread = class(TThread)
IB_Connection: TIB_Connection;

procedure DoTask(aTask: TTask);

TTask = class(TObject)
procedure Execute(aConnection: TIB_Connection); virtual; abstract;

TExecuteTask = class(TTask)
procedure ExecSQL(sql: string);

procedure TWorkerThread .DoTask(aTask: TTask);

and so on - you probably get the idea...

With regards,

Martijn Tonies
InterBase Workbench - the developer tool for InterBase

Firebird Workbench - the developer tool for Firebird

Upscene Productions

"This is an object-oriented system.
If we change anything, the users object."