AlexP wrote:Please specify the task in more details and I'll try to give you a more detailed answer.
Short preamble:
Our application works with Oracle database only.
The nature of our application (*not* dedicated for mobile devices!) is that it needs connection to database (single Oracle session). It cannot work without it.
At startup, immediately after connect to database, we manually set (initialize) some variables in *core* packages on db.
These variables are intensively used in all sources (PL/SQL) on database and are the basis for proper operation of the entire application.
In normal (healthy) situations everything works correctly.
However there are some emergency situations like: session was killed, physical connection was lost. After connection was lost TUniConnection tries to reconnect to the database.
Also, if TUniConnection.Connected = False, opening a query (or executing a stored proc) reconnects to database as well.
You probably say, that program will work, and all queries will works too. Yes.
But the rest of our whole database part - PL/SQL procedures - will NOT (because, new Oracle session = variables in our *core* packages are not initialized)!
So, the best solution for us is to raise exception before TUniQuery.Open, TUniQuery.Execute, etc. when TUniConnection.Connected = False.
We don't want to modify our source code adding extra check of TUniConnection.Connected before any "Open" or "Execute" methods!
Also we don't want to modify original UniDac's source code to achieve desired effect.
In all our source code we use:
TAppConnection = class(TUniConnection)
TAppQuery = class(TUniQuery)
TAppStoredProc = class(TUniStoredProc)
I did some investigation and I found that:
1) covering TUniConnection.IsFailOverAllowed method, successfully blocks "AutoReconnect" after connection was lost (@see TCustomDAConnection.DoError).
Code: Select all
function TAppConnection.IsFailOverAllowed: Boolean; override;
begin
Result := False
end {TAppConnection.IsFailOverAllowed};
2) covering TUniQuery.BeginConnection/TUniStoredProc.BeginConnection method, successfully blocks auto-connecting to database
Code: Select all
procedure TAppQuery.BeginConnection(NoConnectCheck: Boolean); override;
begin
if Assigned(Connection) and (not Connection.Connected) then
Raise Exception.CreateRes(@DAConsts.SConnectionNotConnected);
inherited
end {TAppQuery.BeginConnection};
procedure TAppStoredProc.BeginConnection(NoConnectCheck: Boolean); override;
begin
if Assigned(Connection) and (not Connection.Connected) then
Raise Exception.CreateRes(@DAConsts.SConnectionNotConnected);
inherited
end {TAppStoredProc.BeginConnection};
But this is a half-solution.
Summarize, as You can see, we miss a lot some properties of TUniConnection like:
TUniConnection.AutoReconnect: Boolean;
TUniConnection.AutoConnect: Boolean;
Is my way of thinking is good, and these changes (related with disabling AutoReconnect/AutoConnect to database) correct?
Are there any chances to add these properties in the near future to UniDac components (we believe that this would be the best solution)?