1

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().

JoshDM
  • 4,939
  • 7
  • 43
  • 72
Thunderhashy
  • 5,291
  • 13
  • 43
  • 47

1 Answers1

1

I'm not sure I understand your question, but it seems to me either you don't want the server to start if the exception occurs, or you want to set a static variable that checks if the database is on before trying to contact it (no UnknownHostException when initializing jdbc).

Maybe this points you towards your answer:

http://www.cubrid.org/blog/dev-platform/understanding-jdbc-internals-and-timeout-configuration/

good luck!

Daren
  • 3,337
  • 4
  • 21
  • 35