wood burning stoves 2.0*
The moose likes JDBC and the fly likes Type 4 driver connections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Type 4 driver connections" Watch "Type 4 driver connections" New topic
Author

Type 4 driver connections

David Attard
Greenhorn

Joined: May 13, 2003
Posts: 26
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


There's no place like 127.0.0.1
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
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
 
Consider Paul's rocket mass heater.
 
subject: Type 4 driver connections