• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Type 4 driver connections

 
David Attard
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a custom connection pool, which polls the database server every 2 seconds to query whether the SQL database is still alive. This is done so that if it is determined that the SQL server is dead, the connections are cleared and re-created, thus make sure all connection are fine.
However, my friend, a network engineer told me that any TCP based connection will not die instantly, even if there is a temporary phyiscal disconnection i.e. if the problem arranges itself within some 50 seconds, the TCP based connections will still be ok.
These disconnections may occur frequently due to small changes in firewall maintenance and otherwise, my question is, will the connections be ok, if the connection is restored within a few seconds, and therefore should I increase my polling interval to the "stay-alive" period of the TCP connections?
Thanks
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't worry, this is all handled at the TCP/IP protocol level. If there is a temporary network glitch, I/O will block while the TCP/IP stack tries to recover. If the network remains down, the Socket will eventually time out and throw an IOException which the JDBC driver will turn into an SQLException. If, on the other hand, the problem goes away, then the only consequence is that your once-every-2-seconds check may take a little while to execute.
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic