Connection Pooling

M

Marc

I am reading some book over dotnet. I do not understand this sentence
considering connection pooling:

Enlist When this value is true, the connection is automatically enlisted
into the
creation threads current transaction context. The default is true.

What is enlisted? It's put on some list? And what is the current transaction
context? And why does the creation thread has such a context?

Sorry I do not understand much about this sentence.
 
G

George

In the object oriented world objects work with Database.
So it's common for 2 different objects to update it's own pieces of
databases.
for example:
Let say you have a rule if person withdraws money from his checking account
and do not have balance available the money is taken from his saving
account.
So here is the pseducode.

clsAccount objChecking, objSaving;
.....
if( objChecking.AvailableBalance < NeededAmount )
{
objSavings.Take(NeededAmount);
objChecking.Put(NeededAmount);
}
objChecking.GiveCash(NeededAmount);

If the 'Put' method fails we need to reverse 'Take' action...
in a simple world (not object oriented) you would issue
DBConnection.AbortTransaction and it will be like the method 'Take' never
happened.
But in object oriented world, each object objSavings and objChecking had
created it's own DBConnection and had performed the UPDATE statement on it.

So the question is how do you Abort transaction on 2 separate DB
connections.
So now (when Enlist = true) each connection (opened on current thread) is
enlisted into single 'Global' transaction and if that transaction is aborted
all actions perfomed by this connection will rollback.
-----------------------------
I hope i am clear.

So if you set Enlist = false then you will save some runtime. But then you
will not be able to do rollback of the 'global' transaction. By default all
Global transaction will commit so if you are not doing anything special to
roll them back you can safely set it to Enlist = false. You can keep it as
true but then you just wasting some runtime.

FYI: The service that manages Global transactions is called 'Microsoft
Distributed Transaction Coordinator' you can google it if you want to find
more info. It's comes with Windows.


George.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top