[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Oracle connection/session not closing

Posted on 2012-03-14
2
Medium Priority
?
1,054 Views
Last Modified: 2012-03-15
Following a .net query of an Oracle DB, I issue a conn.close command, but the application session in Oracle remains active until the application is closed.  How do I end the connection and Oracle session once I have retrieved the results of the query?
0
Comment
Question by:mdreed
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37723215
Are you disposing of the reference once you have closed the connection? Also, are you using connection pooling?
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 1500 total points
ID: 37723419
ADO.NET uses a mechanism called connection pooling. When you call Close on a connection object, the physical connection on the server is not closed immediately. It is held open for a certain period, 5 minutes by default for SQL Server, I suppose it is of the same order for Oracle.

If you reopen a connection object with the exact same connectionstring during that timeout period, the same connection is reused. The connection is really closed if you do not use the connection during that time, or if you close the application.

This is actually a good thing.

Before .NET, we used to keep a connection opened as long as the application was active, through a public (global) object. A very bad thing that often caused problems.

It is always better to use local variables when possible. This means that you would normally need to open and close a connection in each method that needs one, even when methods are called in a loop or recursively. This would be very painful on the server, because a opening and closing a connection requires a lot of work (validating the user, managing the users pool, etc.).

Connection pooling is a good compromise.

If you really do not want connection pooling to be active, look through the documentation for your Oracle library. The pool can usually be controlled by specific indications in the connection string.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question