Top Description Fields Constructors Methods
org.springframework.jdbc.support

public Class DatabaseStartupValidator

extends Object
implements InitializingBean
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.InitializingBean
Imports
java.sql.Connection, .SQLException, .Statement, java.util.concurrent.TimeUnit, javax.sql.DataSource, org.apache.commons.logging.Log, .LogFactory, org.springframework.beans.factory.InitializingBean, org.springframework.jdbc.CannotGetJdbcConnectionException, org.springframework.lang.Nullable

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.

Authors
Juergen Hoeller, Marten Deinum
Since
18.12.2003

Field Summary

Modifier and TypeField and Description
private DataSource
public static final int
DEFAULT_INTERVAL

The default interval.

public static final int
DEFAULT_TIMEOUT

The default timeout.

private int
protected final Log
private int
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.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.

public void
setDataSource(DataSource dataSource)

Set the DataSource to validate.

public void
setInterval(int interval)

Set the interval between validation runs (in seconds).

public void
setTimeout(int timeout)

Set the timeout (in seconds) after which a fatal exception will be thrown.

public void
setValidationQuery(String validationQuery)
Deprecated as of 5.3, in favor of the JDBC 4.0 connection validation

Set the SQL query string to use for validation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dataSourceback to summary
private DataSource dataSource
Annotations
@Nullable
DEFAULT_INTERVALback to summary
public static final int DEFAULT_INTERVAL

The default interval.

DEFAULT_TIMEOUTback to summary
public static final int DEFAULT_TIMEOUT

The default timeout.

intervalback to summary
private int interval
loggerback to summary
protected final Log logger
timeoutback to summary
private int timeout
validationQueryback to summary
private String validationQuery
Annotations
@Nullable

Constructor Detail

DatabaseStartupValidatorback to summary
public DatabaseStartupValidator()

Method Detail

afterPropertiesSetback to summary
public void afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.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.

Annotations
@Override
setDataSourceback to summary
public void setDataSource(DataSource dataSource)

Set the DataSource to validate.

setIntervalback to summary
public void setInterval(int interval)

Set the interval between validation runs (in seconds). Default is 1.

setTimeoutback to summary
public void setTimeout(int timeout)

Set the timeout (in seconds) after which a fatal exception will be thrown. Default is 60.

setValidationQueryback to summary
public void setValidationQuery(String validationQuery)

Deprecated

as of 5.3, in favor of the JDBC 4.0 connection validation

Set the SQL query string to use for validation.

Annotations
@Deprecated