Daniel Magin’s Weblog

My life in the Developers World

DBXPooling and Broken Connections

Hi all,

if you use the DBXPooling ehancement in your Delphi 2007 and DBX and your connection to the server is broken, the broken connection goes back in the pool and you get back sometimes this broken connection. So i have changes some lines in the DBXPool.pas (..\program files\codegear\rad studio\5.0\source\database\src\pas\dbx\driver\). In the ReleaseConnection method of the TBXPool class i check to start a transaction and commit it. if it not works something is wrong with the connection and i give this connection not back to pooling container. The Pool is now creating a new connection for you.
Here are the small changes:

procedure TDBXPool.ReleaseConnection(Connection: TDBXConnection);
var
  MyTrans: TDBXTransaction;

begin
  try
     Mytrans:= Connection.BeginTransaction(0);
     Connection.CommitFreeAndNil(MyTrans);
     FCriticalSection.Acquire;
     try
       FAvailableConnectionArray[FAvailableConnections] := Connection;
       inc(FAvailableConnections);
     finally
       FCriticalSection.Release;
     end;
  except
  end;

  FSemaphore.Release;
end;

regards Daniel Magin

Advertisements

May 5, 2008 - Posted by | Embarcadero (CodeGear) stuff

2 Comments »

  1. Why did you put the transaction check code inside the critical section? inc(FAvailableConnections); has to be, but the transaction code itself might introduce an unnecessary bottelneck.

    Comment by Olaf Monien | May 5, 2008 | Reply

  2. hi olaf,

    yes you are right. so i have updated the code.

    thanks and i hope to see you soon

    daniel magin

    Comment by dmagin | May 5, 2008 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: