Page 1 of 1

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

Posted: Wed 15 Jun 2005 11:05
by ender
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! :(

Posted: Wed 15 Jun 2005 11:50
by ender
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.

Posted: Wed 15 Jun 2005 15:44
by Oleg
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.

Posted: Thu 16 Jun 2005 04:09
by ender
Thanks for info. Yes it is connection pooling. I added neccessary value to ConnectionString and connection get closed.