Package org.springframework.jdbc.support

# Class DatabaseStartupValidator

java.lang.Object
org.springframework.jdbc.support.DatabaseStartupValidator

All Implemented Interfaces:
  `org.springframework.beans.factory.InitializingBean`

public class DatabaseStartupValidator extends Object implements org.springframework.beans.factory.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 Summary

Fields
Modifier and Type
Field
Description
`static final int`
`DEFAULT_INTERVAL`
The default interval.
`static final int`
`DEFAULT_TIMEOUT`
The default timeout.
`protected final org.apache.commons.logging.Log`
`logger`

## Constructor Summary

Constructors
Constructor
Description
`DatabaseStartupValidator()`

## Method Summary

Modifier and Type
Method
Description
`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.
`void`
`setDataSource(DataSource dataSource)`
Set the DataSource to validate.
`void`
`setInterval(int interval)`
Set the interval between validation runs (in seconds).
`void`
`setTimeout(int timeout)`
Set the timeout (in seconds) after which a fatal exception will be thrown.
`void`
`setValidationQuery(String validationQuery)`
Deprecated.
as of 5.3, in favor of the JDBC 4.0 connection validation

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### DEFAULT_INTERVAL

public static final int DEFAULT_INTERVAL
The default interval.

See Also:
  - Constant Field Values

### DEFAULT_TIMEOUT

public static final int DEFAULT_TIMEOUT
The default timeout.

See Also:
  - Constant Field Values

### logger

protected final org.apache.commons.logging.Log logger

## Constructor Details

### DatabaseStartupValidator

public DatabaseStartupValidator()

## Method Details

### setDataSource

public void setDataSource(DataSource dataSource)
Set the DataSource to validate.

### setValidationQuery

@Deprecated 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.

### setInterval

public void setInterval(int interval)
Set the interval between validation runs (in seconds). Default is 1.

### setTimeout

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

### afterPropertiesSet

public 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:
  `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`