• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How Stealed connection will exists?

 
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All

As we heard stealed connection's exists because of improper closing of connection in the application. so why cant we use static variables for Connection,ResultSet,Statement and close them using finalize method in my appllication instead of closing the connection in all the methods is it eliminates the stealed connection
 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the previous post

Its stale Connections

 
author & internet detective
Posts: 40198
816
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Santosh,
A stale connection is caused by a timeout with the database. Making a connection a static variable increases the chance of a stale connection. Since the static variable lives for the life of the program, odds are that connection will experience a timeout sooner or later.
 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Making a connection a static variable increases the chance of a stale connection. Since the static variable lives for the life of the program



Is it possible to eliminate the stale connections by making declaring the connection object inside the method (Not declaring as static out side)
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not possible to eliminate stale connections. As Jeanne said, it is caused by a timeout with the DB- and we cannot control that timeout as it is configured at the DB level.

It's best to handle stale connections effectively in your code and get a new connection in case you get one.
    Bookmark Topic Watch Topic
  • New Topic