jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes Type 4 driver connections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Type 4 driver connections" Watch "Type 4 driver connections" New topic

Type 4 driver connections

David Attard

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?

There's no place like
Peter den Haan
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
I agree. Here's the link: http://aspose.com/file-tools
subject: Type 4 driver connections
It's not a secret anymore!