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

Detecting database connection loss

 
Pascal Got
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have an app which connects to a database and perform some query (using SELECT "style" and stored proc) - all working well.
But is there a way to detect loss a connection to my database as soon as it happens (is there an exception or event trigger I can catch or listen to) ? ( so I can auto-reconnect)
Currently, I see loss of connection when I do a query .... which is too late really...
Thx for your help.
Pascal
 
SJ Adnams
Ranch Hand
Posts: 925
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the connection pool we a have a thread that does a 'select * from dual' at every timeperiod in a property file.
why are you getting kicked off? is there a timeout or something in the profile?
 
Pascal Got
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Simon Lee:

why are you getting kicked off? is there a timeout or something in the profile?

No, but we depend on adatabase server which (very rarely) may be bounced... as our system is a 24/7 system, unless we get notify and reconnect, we don't see the connection being dropped.....
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It really depends on the implemetation of your connection pool. JDBC 2.0 std ext. has the class javax.sql.ConnectionEventListener these can be created and attached to each Connection in the Pool. It's distribute now with JDK 1.4. Your pool can implement this and on notification of sever Exception, cleanup the current connections and create a new good set for the pool. http://java.sun.com/j2se/1.4.1/docs/api/javax/sql/ConnectionEventListener.html
[ April 25, 2003: Message edited by: Carl Trusiak ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic