This week's book giveaway is in the Agile and Other Processes forum. We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line! See this thread for details.
It depends purely on how the connection pool is configured. In a simple application, the configuration might be done programmatically, but in many more complex applications, the configuration is handled by the application container. It also depends on the specific JDBC driver that is being used. Some drivers might not even support any configuration of the kind at all.
Are you an application developer? If so, why do you care?
Actually, barring termination of the JVM, the connection will close when it times out on the database server. That is, it's not the "Connection" that times out, it's the (network) connection.
That has been a particular problem for webapp servers keeping a Connection Pool, since connections could expire while in the pool. So various mechanisms exist to check for a dead connection and, if necessary, replace it with a new one.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
My pie came with a little toothpic holding up this tiny ad:
a bit of art, as a gift, the permaculture playing cards