diff --git a/common/src/main/java/com/metamx/druid/db/DbConnector.java b/common/src/main/java/com/metamx/druid/db/DbConnector.java index b8ab7a4747e..76dc1876898 100644 --- a/common/src/main/java/com/metamx/druid/db/DbConnector.java +++ b/common/src/main/java/com/metamx/druid/db/DbConnector.java @@ -125,6 +125,11 @@ public class DbConnector dataSource.setPassword(config.getDatabasePassword()); dataSource.setUrl(config.getDatabaseConnectURI()); + if (config.isValidationQuery()) { + dataSource.setValidationQuery("SELECT 1"); + dataSource.setTestOnBorrow(true); + } + return dataSource; } } diff --git a/common/src/main/java/com/metamx/druid/db/DbConnectorConfig.java b/common/src/main/java/com/metamx/druid/db/DbConnectorConfig.java index b1a9a1b3e2e..bde292e8cae 100644 --- a/common/src/main/java/com/metamx/druid/db/DbConnectorConfig.java +++ b/common/src/main/java/com/metamx/druid/db/DbConnectorConfig.java @@ -41,4 +41,10 @@ public abstract class DbConnectorConfig @JsonProperty("segmentTable") @Config("druid.database.segmentTable") public abstract String getSegmentTable(); + + @JsonProperty("validationQuery") + @Config("druid.database.validation") + public boolean isValidationQuery() { + return false; + } }