Package org.springframework.jdbc.support
Class DatabaseStartupValidator
java.lang.Object
org.springframework.jdbc.support.DatabaseStartupValidator
- All Implemented Interfaces:
- InitializingBean
Bean that checks if a database has already started up. To be referenced
 via "depends-on" from beans that depend on database startup, like a Hibernate
 SessionFactory or custom data access objects that access a DataSource directly.
 
Useful to defer application initialization until a database has started up. Particularly appropriate for waiting on a slowly starting Oracle database.
- Since:
- 18.12.2003
- Author:
- Juergen Hoeller, Marten Deinum
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intThe default interval.static final intThe default timeout.protected final Log
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidCheck whether the validation query can be executed on a Connection from the specified DataSource, with the specified interval between checks, until the specified timeout.voidsetDataSource(DataSource dataSource) Set the DataSource to validate.voidsetInterval(int interval) Set the interval between validation runs (in seconds).voidsetTimeout(int timeout) Set the timeout (in seconds) after which a fatal exception will be thrown.voidsetValidationQuery(String validationQuery) Deprecated.as of 5.3, in favor of the JDBC 4.0 connection validation
- 
Field Details- 
DEFAULT_INTERVALpublic static final int DEFAULT_INTERVALThe default interval.- See Also:
 
- 
DEFAULT_TIMEOUTpublic static final int DEFAULT_TIMEOUTThe default timeout.- See Also:
 
- 
logger
 
- 
- 
Constructor Details- 
DatabaseStartupValidatorpublic DatabaseStartupValidator()
 
- 
- 
Method Details- 
setDataSourceSet the DataSource to validate.
- 
setValidationQueryDeprecated.as of 5.3, in favor of the JDBC 4.0 connection validationSet the SQL query string to use for validation.
- 
setIntervalpublic void setInterval(int interval) Set the interval between validation runs (in seconds). Default is 1.
- 
setTimeoutpublic void setTimeout(int timeout) Set the timeout (in seconds) after which a fatal exception will be thrown. Default is 60.
- 
afterPropertiesSetpublic void afterPropertiesSet()Check whether the validation query can be executed on a Connection from the specified DataSource, with the specified interval between checks, until the specified timeout.- Specified by:
- afterPropertiesSetin interface- InitializingBean
 
 
-