Additional
dbCAP
AnyDAC
ThinDAC
NCOCI8
Topic: How to solve DB Connection Monitoring
How to solve DB Connection Monitoring
Posted: 2007/06/28 08:06
 
I have the problem that one of my bigger clients is constantly changing his infrastructure. This means that sometimes network connections are broking, resulting in broken database connections.
How would I monitor the state of a db connection so that a connection could possibly be repaired by reconnecting.
At the moment I can't reach the pooled connections hidden in TTDSQLDriver

Any thoughts how to solve my problem

Arjan
Re:How to solve DB Connection Monitoring
Posted: 2007/06/28 08:22
 
Hello

1) If I am getting you right, you need to check is the connection alive right after getting it from the pool. And if it is not alive, then reconnect DB connection object. Is that right ?
2) What is your DBMS ?

Regards,
Dmitry
Re:How to solve DB Connection Monitoring
Posted: 2007/06/29 01:46
 
Yes, that's right. Am using ADO with msSQL 2005

Post edited by: ArjanNoordhoek, at: 2007/06/29 03:15
Re:How to solve DB Connection Monitoring
Posted: 2007/06/29 05:28
 
You can try following:

1) If there is not a big workload on the server, then just set TTDADODriver.Pooled = False.

2) In TTDADODriver.AfterGetDataSet event hanlder you can verify current connection state and if required, then reestablish it:


 if not CheckReallyConnected(TADOQuery(ADataSet).Connectionthen begin   TADOQuery(ADataSet).Connection.Connected := False;   TADOQuery(ADataSet).Connection.Connected := True; end;



There CheckReallyConnected will be your own function, checking ADO connection state.

Rgards,
Dmitry