Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How Stealed connection will exists?

 
santhosh.R gowda
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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • 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)
 
Sandeep Sanaboyina
Ranch Hand
Posts: 72
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic