DbConnector: Optional validation query (default off for now)

This commit is contained in:
Gian Merlino 2013-04-19 14:04:10 -07:00
parent cc30dfad2f
commit 1dfe133554
2 changed files with 11 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}