| Author |
What happens if Database Connections not closed?
|
yamini nadella
Ranch Hand
Joined: Apr 13, 2004
Posts: 257
|
|
|
I have a java application and Sql server database. In java application I am opening a database connection and not closing that DB connection. According to my understanding once we exit java application then all opened database connections from this application will be closed automatically. Is it not?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56185
|
|
|
Even if they are, do you really think that's a good idea?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Jeffrey Hunter
Ranch Hand
Joined: Apr 16, 2004
Posts: 305
|
|
|
Not from my experience. Even after our application exited normally, we noticed several JDBC thin clients still connected to the Oracle DB. These were instances where developers overlooked closing connections, or failed to control for exceptions. I think the safe, simple rule to follow is: close all your connections explicitly.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26183
|
|
Yamini,
According to my understanding once we exit java application then all opened database connections from this application will be closed automatically
First of all, I agree with everyone who has said to close the connection. It is a good habit and important to do. The connection being closed isn't tied to the application exiting though. It is tied to the database connection timeout. When a connection hasn't been used in a certain length of time, it can (sometimes) be recovered. The connection pool does not know whether the application has exited.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: What happens if Database Connections not closed?
|
|
|