2

Using JDBC to connect to a Derby database, after a while, Derby or JDBC close the connection automatically. (This may be called a "connection lifetime" value or a timeout value).

Where can I find out what the timeout value is? Is it Derby or JDBC that closes the connection? Is it an "idle timeout" value, so, if there is activity on that connection, will Derby or JDBC update so it closes the connection at (LastActivity + IdleTimeoutValue)?

I looked at a bunch of pages, including Connection timeout for DriverManager getConnection How to reestablish a JDBC connection after a timeout?

Community
  • 1
  • 1
Mary
  • 552
  • 1
  • 8
  • 21

1 Answers1

1

Neither Derby nor JDBC has any automatic timeout, so far as I know.

Here are the configurable behaviors of a Derby JDBC connnection: http://db.apache.org/derby/docs/10.8/ref/rrefattrib24612.html

I don't think that Derby is closing your connection.

I suspect that you have a network firewall, or VPN, or some other piece of equipment which is closing your apparently-idle TCP/IP connections.

Try reviewing your network configuration with your IT staff.

Bryan Pendleton
  • 16,128
  • 3
  • 32
  • 56
  • If neither Derby nor JDBC close a connection due to inactivity, then either the info in the two links (in the original post/question) is incorrect, or I misunderstand what they are saying. Any ideas? – Mary Jul 18 '12 at 20:50
  • This may be leading to another area, TCP keepalive; if that's the issue, either it's set at the OS level, or somehow to tell Derby to use keepalive (it's not in the derby configurable behaviors document). I also use ActiveMq, so would have to tell ActiveMq's sockets to keep alive also. If there's an article about how to configure and program for these kinds of issues, I'd like to read it! – Mary Jul 19 '12 at 01:05
  • To be more precise, what I meant was that Derby's implementation of JDBC does not close an idle connection due to timeout, and JDBC does not require such a feature. Indeed, other JDBC implementations might provide such a feature, as you linked to in your original question. Again, you should ask your IT staff to help enable network-layer diagnostics to figure out why your idle connection is being closed, because I don't believe it's Derby that's doing it. – Bryan Pendleton Jul 19 '12 at 13:58
  • You may be right, the remote connection to the computer goes dead also, and we must reconnect. Something in our network can be frying all the connections regularly (I suspect DHCP lease). I will update this comment as I find out more. I'm suspecting the WGR614v10 netgear router, though there are other switches in the network to suspect as well. – Mary Jul 19 '12 at 15:11
  • Low-tech test: we turned off the network switch for 30 seconds while a job was running, got the same kind of results. More updates to come. – Mary Jul 19 '12 at 20:25
  • I put a few computers on a simple switch, fixed IP addresses (no DHCP), and they have been running OK. So it IS something on the network (probably whatever device doing DHCP, holding NAT states) that's resetting all the connections periodically. Final conclusion: It's not Derby or JDBC dropping an idle connection. – Mary Jul 25 '12 at 15:29