473,387 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

OracleConnection

Hi - is it the case that OracleConnection does not call close when the
connection is disposed?

For example, I use this sort of construct:

using (OracleConnection conn = GetConnection())
{
using (OracleTransaction tx = conn.BeginTransaction())
{
using (OracleCommand command = conn.CreateCommand())
etc.

But now a colleague tells me that the connection is not closed when the
using clause ends. Can this be true? Is that not a serious bug in
OracleConnection?

Or could it be affected by the "GetConnection" method which is a call to a
third-party class which actually gives us a connection - I mean, could
GetConnection somehow affect the subsequent "dispose" behaviour of the
connection?

Thanks,
Peter
Nov 7 '07 #1
6 4462
Peter,

What makes you think that it is not being closed? If you are using
connection pooling, then you might see the connection open still (not to
your code through the OracleConnection class, but through a performance
counter, for example). Other than that, the code you wrote will call the
Dispose method on the connection, which will close the connection.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Peter K" <xd****@hotmail.comwrote in message
news:eQ**************@TK2MSFTNGP03.phx.gbl...
Hi - is it the case that OracleConnection does not call close when the
connection is disposed?

For example, I use this sort of construct:

using (OracleConnection conn = GetConnection())
{
using (OracleTransaction tx = conn.BeginTransaction())
{
using (OracleCommand command = conn.CreateCommand())
etc.

But now a colleague tells me that the connection is not closed when the
using clause ends. Can this be true? Is that not a serious bug in
OracleConnection?

Or could it be affected by the "GetConnection" method which is a call to a
third-party class which actually gives us a connection - I mean, could
GetConnection somehow affect the subsequent "dispose" behaviour of the
connection?

Thanks,
Peter

Nov 7 '07 #2
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote
in news:OC**************@TK2MSFTNGP03.phx.gbl:
Peter,

What makes you think that it is not being closed? If you are
using
connection pooling, then you might see the connection open still (not
to your code through the OracleConnection class, but through a
performance counter, for example). Other than that, the code you
wrote will call the Dispose method on the connection, which will close
the connection.
Hi thanks, these were also my thoughts. I have no evidence that
OracleConnection does not behave as expected - a colleague has just told me
I need to explictly close my connections because OracleConnection does not
function correctly on a dispose (ie at the end of a using clause).

I have not yet heard back from him about how he has ascertained this.
Nov 7 '07 #3
Peter K wrote:
Hi - is it the case that OracleConnection does not call close when
the connection is disposed?

For example, I use this sort of construct:

using (OracleConnection conn = GetConnection())
{
using (OracleTransaction tx = conn.BeginTransaction())
{
using (OracleCommand command = conn.CreateCommand())
etc.

But now a colleague tells me that the connection is not closed when
the using clause ends. Can this be true? Is that not a serious bug in
OracleConnection?

Or could it be affected by the "GetConnection" method which is a call
to a third-party class which actually gives us a connection - I mean,
could GetConnection somehow affect the subsequent "dispose" behaviour
of the connection?
ODP.NET or MS Oracle client?

ODP.NET has a lot of tiny little quircks, like calling Dispose on
every element or else you'll have memory leaks etc. Though I don't
think any ADO.NET provider leaves a connection open when dispose is
called, simply because the connection has to be cleaned up to make
dispose do its job :)

Closing a connection will make it go to the pool, which means the
connection physically stays open for some time. Perhaps your collegue
meant that, although with close you can't change that behavior. (nor
should you want to)

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Nov 8 '07 #4
"Frans Bouma [C# MVP]" <pe******************@xs4all.nlwrote in
news:xn***************@news.microsoft.com:
ODP.NET or MS Oracle client?

ODP.NET has a lot of tiny little quircks, like calling Dispose on
every element or else you'll have memory leaks etc. Though I don't
think any ADO.NET provider leaves a connection open when dispose is
called, simply because the connection has to be cleaned up to make
dispose do its job :)

Closing a connection will make it go to the pool, which means the
connection physically stays open for some time. Perhaps your collegue
meant that, although with close you can't change that behavior. (nor
should you want to)
Hi there

We are using Oracle.DataAccess.Client.OracleConnection.

I wasn't really aware of the different connection objects one could use. Do
you have references to the different types?

Thanks,
Peter
Nov 8 '07 #5
Peter K wrote:
"Frans Bouma [C# MVP]" <pe******************@xs4all.nlwrote in
news:xn***************@news.microsoft.com:
ODP.NET or MS Oracle client?

ODP.NET has a lot of tiny little quircks, like calling Dispose
on every element or else you'll have memory leaks etc. Though I
don't think any ADO.NET provider leaves a connection open when
dispose is called, simply because the connection has to be cleaned
up to make dispose do its job :)

Closing a connection will make it go to the pool, which means
the connection physically stays open for some time. Perhaps your
collegue meant that, although with close you can't change that
behavior. (nor should you want to)

Hi there

We are using Oracle.DataAccess.Client.OracleConnection.

I wasn't really aware of the different connection objects one could
use. Do you have references to the different types?
You're using ODP.NET, which is preferable over Microsoft's own Oracle
ADO.NET client in .NET. ODP.NET is released by Oracle, and has more
features. The only downside is that it's still a wrapper around its own
Java based CLI, so you do have to call Dispose() on OracleParameter
objects for example otherwise you'll get memory leaks

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Nov 9 '07 #6
Frans Bouma [C# MVP] wrote:
You're using ODP.NET, which is preferable over Microsoft's own Oracle
ADO.NET client in .NET. ODP.NET is released by Oracle, and has more
features. The only downside is that it's still a wrapper around its own
Java based CLI, so you do have to call Dispose() on OracleParameter
objects for example otherwise you'll get memory leaks
Java based CLI ??

Do you mean native OCI ?

Arne
Nov 19 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kevin Vogt | last post by:
When initially loaded, my web application (below) takes ~120000 milliseconds to open its connection. But repeated executions take 0 milliseconds each. But when I wait for approx. 5 minutes and try...
6
by: Raphaël ARBUZ | last post by:
Hi everybody I have tried to create a Windows Application with an Oracle Connection to a base, but each time the program comes to my line : Connection1.Open(); it generates an exception.in...
0
by: ʹÃûÑï | last post by:
ORA-03114: not connected to ORACLE && MS's Bug?? DataBase:Oracle 817 using OracleClient,net framework 1.1 I'm using ADO.Net in C# with Oracle 817. and following is my public data access...
1
by: ÍõÑå¾ý | last post by:
Is there a way to connect the oracle server without a oracle client software?
2
by: honeygracee | last post by:
hi i am doing a program and i need to connect 5 projects in 1 solution but right now i am only doing the first project to be connected to the oracle connnection. can you help me on how can i view...
3
by: Peter Kanurer | last post by:
I thought "using System.DataAccess.Client" would contain all necessary stuff for OracleConnection, OracleCommand and OracleDataReader objects but this is not the case. They are still...
2
by: Werner Sammer | last post by:
I tried to connect to an existing Oracle Database with the following ConnectionString: using System.Data.OracleClient; // + Added Reference "System.Data.OracleClient" string cs = "Data...
1
by: walterb | last post by:
I had a hard time finding this information on the web, so I decided to post it here for someone else. I was finding it difficult to locate information on the proper method to store the database...
7
by: BiffMaGriff | last post by:
I have an query I run against an Oracle Connection. I have these objects, an event table and a table to map my objects to my events. My select statement selects the most recent event for each...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.