Q:

How long does a JDBC connection live if not closed in java code?

If I open up a JDBC connection in my java code and forget  to close it, will it remain open for ever? Or is there a default time out value that I can specify somewhere?

A:

In first place, you really need to fix the code to close it. No excuses.
As to the concrete question, that depends on the DB server used. It's the DB server who will timeout and reclaim it. Refer the DB server specific administration manual for defaults and how to change it. In case of for example MySQL, it's the wait_timeout setting which defaults to 28800 seconds (8 hours).

