Page 1 of 1

TUniQuery & Connection timeout expired

Posted: Tue 06 Sep 2011 15:07
by cooler
Hello,

I'm using TUniQuery in disconnected mode, to connect to a PostgreSQL. It works very well, but sometimes I get an error:
Cannot connect to database
Connection timeout expired

It's shown when i'm trying to open the query or ApplyUpdates on this query.

Example 1:

Code: Select all

try{
	uniQueryMaster->ParamByName("master_id")->AsInteger = master_id;
	uniConnection->Connect();
	uniQueryMaster->Open();
	uniQueryDetail->Open();
	uniConnection->Disconnect();
}
catch(EDAError& e){
	//...
}
catch(Exception& e){
	//This code is called with the e.message: 
	//Cannot connect to database
	//Connection timeout expired
}
Example 2:

Code: Select all

try{
	uniConnection->ApplyUpdates();
	uniQueryMaster->Open();
	uniQueryDetail->Open();
}
catch(Exception& e){
	//This code is called with the e.message: 
	//Cannot connect to database
	//Connection timeout expired
}
  • - uniConnection->Options->LocalFailOver is set to true, without OnConnectionLost event handler.
    - uniQuery->CachedUpdates is set to true, both (master and detail).
My customer getting this error sometimes, not always. After this error is shown it is possible to open or save that Query.

What should I do to avoid this error?

Thanks

---
UNIDAC: 3.70.0.18
C++ Builder: XE

Posted: Wed 14 Sep 2011 10:44
by AlexP
Hello,

If you are using the disconnect mode, you don't need to call the Connect and Disconnect methods, because connecting to database is performed automatically when an attempt to open DataSet, call a procedure, etc is made; also connection will be closed automatically when all data is received from server. Besides, to execute an operation on which connection was closed once more, you should set the RetryMode parameter in the onConnectionLost event to rmReconnectExecute.