Subject | IBO with Multithreading and connection pool |
---|---|
Author | djsushie |
Post date | 2005-07-28T20:20:27Z |
Hi,
We're developing a multithreaded app using D5 Ent with IBO4, FB 1. We
have implemented our own connection pool mechanism, where a Firebird
connection comprises of an IB_Connection and an IB_Transaction placed
on a TDataModule.
The application can create multiples of such datamodules, so as to
maintain a pool of free open connections.
The processing is performed in another set of DataModule objects,
which are created as required when processing and freed once complete.
Each processing object has multiple TIBOQuery components, and an
IB_Session (which is the first component listed inside of the dfm when
opened as text - i hope this is the meaning of 'created first').
The processing objects' constructor(thus running in the main thread)
picks one of the free connection Datamodules and links the IBOQuery's
IB_Connection and IB_Transaction pointers to the components on the
connection datamodule. It also links the IB_Session to the
IB_Connection.
Only after this is over that the thread kicks in and runs sqls through
the IBOQuerys.
Note that ib components are not being created at runtime (through
code) because i prefer to have the compile-time fieldname checks.
The connection is through TCPIP.
There doesnt seem to be a problem with the overall code because the
pool also has BDE components linking to an oracle db in a similar
fashion, and those work fine (linking through uniquely generated
DatabaseName and SessionName properties)
Now, we have faced several kinds of errors, depending on where we
place the TIB_Session and TIB_Transaction. I would like to have your
comments on this mechanism i have used.
Also, is the TIB_Session in the right datamodule? (with the IBOQuerys,
and dynamically linked to an IB_Connection)
Also, i have read in an earlier post about a 'SetSession' function,
though this is not documented anywhere in the help. Is this a possible
mechanism to explicitly link an IBOQuery to an IB_Session (even though
the session was possibly created sometime after the query was
created?)
Best Regards,
Sushant.
We're developing a multithreaded app using D5 Ent with IBO4, FB 1. We
have implemented our own connection pool mechanism, where a Firebird
connection comprises of an IB_Connection and an IB_Transaction placed
on a TDataModule.
The application can create multiples of such datamodules, so as to
maintain a pool of free open connections.
The processing is performed in another set of DataModule objects,
which are created as required when processing and freed once complete.
Each processing object has multiple TIBOQuery components, and an
IB_Session (which is the first component listed inside of the dfm when
opened as text - i hope this is the meaning of 'created first').
The processing objects' constructor(thus running in the main thread)
picks one of the free connection Datamodules and links the IBOQuery's
IB_Connection and IB_Transaction pointers to the components on the
connection datamodule. It also links the IB_Session to the
IB_Connection.
Only after this is over that the thread kicks in and runs sqls through
the IBOQuerys.
Note that ib components are not being created at runtime (through
code) because i prefer to have the compile-time fieldname checks.
The connection is through TCPIP.
There doesnt seem to be a problem with the overall code because the
pool also has BDE components linking to an oracle db in a similar
fashion, and those work fine (linking through uniquely generated
DatabaseName and SessionName properties)
Now, we have faced several kinds of errors, depending on where we
place the TIB_Session and TIB_Transaction. I would like to have your
comments on this mechanism i have used.
Also, is the TIB_Session in the right datamodule? (with the IBOQuerys,
and dynamically linked to an IB_Connection)
Also, i have read in an earlier post about a 'SetSession' function,
though this is not documented anywhere in the help. Is this a possible
mechanism to explicitly link an IBOQuery to an IB_Session (even though
the session was possibly created sometime after the query was
created?)
Best Regards,
Sushant.