Delphi 2005. OracleConnection.Close actually does not close connection.

Delphi 2005. OracleConnection.Close actually does not close connection.

Postby ender » Wed 15 Jun 2005 11:05

I'm execute simple test application:
Code: Select all
program crlabconnection;

{$APPTYPE CONSOLE}

{%DelphiDotNetAssemblyCompiler 'c:\program files\corelab\oradirect.net\CoreLab.Oracle.dll'}

uses
   SysUtils,
   CoreLab.Oracle;

var
   Conn:OracleConnection;
   Query:OracleCommand;
   R:OracleDataReader;
   S:OracleString;
   I:Integer;
begin
   Conn:=OracleConnection.Create('User Id=chtpz;Password=w;Data Source=garnet');
   try
      Conn.Open;
      Query:=OracleCommand.Create('select * from USER_LIBRARIES',Conn);
      R:=Query.ExecuteReader;
      try
         while R.Read do
            begin
               for I:=0 to R.FieldCount-1 do
                  begin
                     S:=R.GetOracleString(I);
                     if I=0 then
                        Write(S.Value)
                     else
                        Write('; ',S.Value);
                  end;
               WriteLn;
            end;
      finally
         R.Close;
      end;
   finally
      Conn.Close;
   end;
   WriteLn('Press Enter key...');
   ReadLn;
end.


After console application print "Press Enter key..." prompt i'm go to OEM or T.O.A.D. or just make simple select from V$SESSION and notice that session actually still there. It is inactive, but it still mainained by the application. To end session i need to close application.

I'm think it is a bug! :(
ender
 
Posts: 14
Joined: Mon 06 Jun 2005 11:32

Postby ender » Wed 15 Jun 2005 11:50

Even simple connect/disconnect leave connection with Oracle active.
Code: Select all
program crlabconnection;

{$APPTYPE CONSOLE}

{%DelphiDotNetAssemblyCompiler 'c:\program files\corelab\oradirect.net\CoreLab.Oracle.dll'}

uses
   SysUtils,
   CoreLab.Oracle;
var
   Conn:OracleConnection;
begin
   Conn:=OracleConnection.Create('User Id=chtpz;Password=w;Data Source=garnet');
   try
      Conn.Open;
   finally
      // Conn.Close;
      Conn.Dispose;
   end;
   WriteLn('Press Enter key...');
   ReadLn;
end.
ender
 
Posts: 14
Joined: Mon 06 Jun 2005 11:32

Postby Oleg » Wed 15 Jun 2005 15:44

This behaviour concerns connection pooling, when you call .Close method a connection isn't not closed but added to the pool. When you open a connection is drawn from the pool. You can read about using connection pooling in the documentation for OraDirect .NET and MSDN. If you need to disable connection pooling you should add parameter pooling = false in your connection string.
Oleg
Devart Team
 
Posts: 264
Joined: Thu 28 Oct 2004 13:56

Postby ender » Thu 16 Jun 2005 04:09

Thanks for info. Yes it is connection pooling. I added neccessary value to ConnectionString and connection get closed.
ender
 
Posts: 14
Joined: Mon 06 Jun 2005 11:32


Return to dotConnect for Oracle