Checking Connection to Database

Ricardo

Member
Sometimes my OracleSession loses the connection to the database.

The CheckConnection method resolves parcially the problem.

I want to know if it is possible to generate an event in TOracleSession when a TOracleDataSet or a TOracleQuery is executed.
In that case I would write code in that event to check the connection.

I want to avoid writing code in all Datasets.

Thanks,
RF
 
You can derive your own version of TOracleQuery where you overrides the Execute method where you check and try to reconnect.

You onl yhave to replace all TOracleQuery instances in your project by your own Query object.

Code:
PROCEDURE TMyOraQuery.Execute;
BEGIN
  // check and try to reconnect
  IF Session.CheckConnection(TRUE)=ccError
    // not connected
    THEN EXIT; (or raise exception, ...)
  INHRITED Execute;
END;

Oliver
 
Back
Top