Connect to Oracle when service is starting...

rdeutsch

Member
I am writing a serviceapplication with doa. When the service is starting after a reboot of the server - how can the service detect that oracle is running.
 
You can check the availability of Oracle by using TOracleSession.CheckConnection. If connection has lost, you can use the method TOracleSession.Reconnect to reinstall the connection.

------------------
Oliver Kaesmann
 
If you attempt to make a connection with a database instance that is not started you should get an ORA-01034 error (ORACLE not available). You can test for this in your service:

Code:
try
  MySession.Connected := True;
except
  on E: EOracleError do
  begin
    if E.ErrorCode = 01034 then
      ShowMessage('Instance not started')
    else
      ShowMessage(E.Message);
  end;
end;

------------------
Marco Kalter
Allround Automations
 
Is TOracleSession.Reconnect still a valid method? It's not in the documentation. It worked with v3.4.6.4 but when I tried to recompile with v4.0.7 I received an error: "Undeclared Identifier: 'Reconnect'".

Should TOracleSession.CheckConnection(Reconnect: Boolean) be used instead?

Thanks.
 
How should we react when the connection with Oracle is lost?

Is a Reconnect property (boolean default True) not a valid option? Should the OracleSession not check the connection before each transaction?

Or, if this is too much overhead, an OnConnectionLost event where we can try to reconnect.
 
This would indeed cause some overhead. It may also require additional application logic to recover from a lost connection, depending on where, when and how the connection was lost. It's not so easy to handle this completely transparent in the background.
 
Back
Top