Connections and transactions

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Boro
Posts: 21
Joined: Wed 19 Sep 2007 21:58

Connections and transactions

Post by Boro » Tue 16 Oct 2007 11:08

Hi,

please what is the advantage of linking multiple TIBCTransaction components with a single TIBCConnection component ? For what situation is this intended ?
What advantages has the usage of multiple connections ?
Perhaps also what is the purpose of linking multiple TIBCConections with a single TIBCTransaction ?

This is a newbie question. Untill now I have used two transactions - one for read and one for write with different isolation levels.
Could I run more transactions independently when they are linked with a single connection ?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Wed 17 Oct 2007 08:34

You can link several TIBCTransaction components to one TIBCConection component, to use independent parallel transactions with one connection. Set the Transaction or/and UpdateTransaction properties of TIBCQuery and TIBCSQL to the corresponding TIBCTransaction component. When you call the Commit method of TIBCTransaction component, only changes that are made through TIBCQuery and TIBCSQL components linked to this transaction is committed.

You also can create a distributed transaction by linking several TIBCConnection components to one TIBCTransaction component. This allows you to create a transaction on several databases. If an error occurs on committing the changes on one database, you can rollback all changes on all databases.

Boro
Posts: 21
Joined: Wed 19 Sep 2007 21:58

Post by Boro » Wed 17 Oct 2007 08:47

Thank you, Plash.
Please, are there situations where an application could need multiple connections to the same database ?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 18 Oct 2007 09:23

If there are several users in the database, an application could use multiple connections for different users. I think there is no sense to create multiple connections with identical parameters.

Boro
Posts: 21
Joined: Wed 19 Sep 2007 21:58

Post by Boro » Fri 19 Oct 2007 05:47

And for multiple threads of a single application ? Shouldn't each thread have own connection with identical parameters ?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Fri 19 Oct 2007 09:39

Yes, it is recommended to use a separate connection for each thread.

Post Reply