Cannot disable auto reconnect

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for Oracle in Delphi and C++Builder
Post Reply
uno
Posts: 3
Joined: Thu 18 Feb 2016 07:41

Cannot disable auto reconnect

Post by uno » Thu 18 Feb 2016 07:54

Hello,
If oracle session has been killed, reconnect occurs when I set TSQLStoredProc.ProcedureName

Found this http://forums.devart.com/viewtopic.php? ... ect#p92780

To disable auto-reconnecting to the server, you should set the Reconnect parameter to False

SQLConnection1.Params.Values['Reconnect'] := 'False';


but that does not work for me
version 5.1.3.0 delphi xe2

Thanks

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Cannot disable auto reconnect

Post by AlexP » Mon 22 Feb 2016 13:12

Hello,

The Reconnect parameter is only responsible for connection when the connection is broken. As I wrote earlier, the error occurring when setting a procedure name is restrained inside DBExpress in the TCustomSQLDataSet.SetParamsFromProcedure method and is not transmitted to the outside.

P.S. dbExpress driver for Oracle 6.7.1

uno
Posts: 3
Joined: Thu 18 Feb 2016 07:41

Re: Cannot disable auto reconnect

Post by uno » Wed 24 Feb 2016 07:58

Connection is broken (session is killed from another session)
Reconnect parameter is set to False

but connection is established again

is there a way to prevent reconnectiong? what do i do wrong?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Cannot disable auto reconnect

Post by AlexP » Wed 24 Feb 2016 09:25

We can't reproduce this behavior on the latest driver version 6.7.11. Please execute the following code and let us know the result.

Code: Select all

program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  SysUtils,
  SqlExpr,
  DB,
  DBXDevartOracle;

var
  SQLConnection, SQLConnectionKill: TSQLConnection;
  SQLQueryKill: TSQLQuery;
  SQLStoredProc: TSQLStoredProc;

begin
  SQLConnection := TSQLConnection.Create(nil);
  try
    SQLConnection.LibraryName := 'dbexpoda40.dll';
    SQLConnection.DriverName := 'DevartOracle';
    SQLConnection.GetDriverFunc := 'getSQLDriverORA';
    SQLConnection.VendorLib := 'oci.dll';
    SQLConnection.Params.Values['Reconnect'] :=  'False';

    SQLConnection.LoginPrompt := false;
    SQLConnection.Params.Add('Database=orcl');
    SQLConnection.Params.Add('User_Name=scott');
    SQLConnection.Params.Add('Password=tiger');
    SQLConnection.Connected := true;
    SQLStoredProc := TSQLStoredProc.Create(nil);
    try
      SQLStoredProc.SQLConnection := SQLConnection;
      SQLConnectionKill := TSQLConnection.Create(nil);
      try
        SQLConnectionKill.LibraryName := 'dbexpoda40.dll';
        SQLConnectionKill.DriverName := 'DevartOracle';
        SQLConnectionKill.GetDriverFunc := 'getSQLDriverORA';
        SQLConnectionKill.VendorLib := 'oci.dll';
        SQLConnectionKill.LoginPrompt := false;
        SQLConnectionKill.Params.Add('Database=orcl');
        SQLConnectionKill.Params.Add('User_Name=sys');
        SQLConnectionKill.Params.Add('Password=********');
        SQLConnectionKill.Params.Add('RoleName=SYSDBA');
        SQLConnectionKill.Connected := True;
        SQLQueryKill := TSQLQuery.Create(nil);
        SQLQueryKill.SQLConnection := SQLConnectionKill;
        SQLQueryKill.SQL.Text := 'select sid||'',''||serial#||'',@''||inst_id from gv$session where username=''SCOTT''';
        SQLQueryKill.Open;
        SQLConnectionKill.ExecuteDirect('alter system kill session ''' + SQLQueryKill.Fields[0].AsString + '''');
        SQLQueryKill.Close;
        try
          SQLStoredProc.StoredProcName := 'SP_TEST';
        except
          on E: Exception do
            Writeln(e.Message);
        end;
        SQLQueryKill.Open;
        if not SQLQueryKill.IsEmpty then
          Writeln('Error')
        else
          Writeln('Ok')
      finally
        SQLConnectionKill.Free;
      end;
    finally
      SQLStoredProc.Free;
    end;
  finally
    SQLConnection.Free;
    Readln;
  end;
end.

uno
Posts: 3
Joined: Thu 18 Feb 2016 07:41

Re: Cannot disable auto reconnect

Post by uno » Wed 24 Feb 2016 12:32

That works fine on the version 5.1.3

we found out that the problem appeared when LoadParamsOnConnect parameter had been set to True

Thank you very much!

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Cannot disable auto reconnect

Post by AlexP » Wed 24 Feb 2016 13:03

glad to see that you solved the problem. If you have any other questions, feel free to contact us

Post Reply