I am using the Spring JDBC template and a BoneCP Connection Pool. When I purposely set the JDBC URL to an invalid value (to test how my system works on failed database connectivity), it throws an UnknownHostException
on server start-up, but the server continues to start. When I submit a request, the jdbcTemplate.query(sql)
method hangs. What is a good way to handle this so the system doesn't hang in jdbcTemplate.query(sql)
?
This scenario is possible if the database is down due to network connectivity issues. I tried to play around with the idleMaxAgeInSeconds
and maxConnectionAgeInSeconds
values; I set them both to 10, but the code still hangs in jdbcTemplate.query()
.